C and C++ Source Code Snippets

Welcome to Cprogramming.com's programming code snippet repository. Peruse the archives or add your own snippets for others to use! (Check the following link a better definition of a snippet)

Sort by clicking on any of the headers.

SnippetAuthorLanguagePlatformRating (votes)
Simple swapping heapsortyzb3 C or C++ANSI10. (3)
View the format of IEEE 754 floating point numbersAli Murad C++ANSI10. (7)
Examples of dynamic multidimensional arraysAli Murad C++ANSI10. (1)
Failproof xor (en/de)cryptionyzb3 CANSI10. (1)
xor (en/de)cryption using a key fileyzb3 CANSI10. (1)
Templated queue classAli Murad C++ANSI9.4 (5)
An example of using the same variable name in different scopesAli Murad C++ANSI9.3 (6)
Templated stack class Ali Murad C++ANSI9.0 (1)
Initial values for static multidimensional arrayAli Murad C or C++ANSI8.3 (8)
Example of polymorphismAli Murad C++ANSI8.2 (5)
Find size and storage capacity of primitive data typesAli Murad C++ANSI7.8 (5)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI7.2 (15)
Permutation GeneratorTreenef C++ANSI7.2 (298)
useful macros, functions and tricksyzb3 CANSI7.0 (1)
Word wrap functionSean Hubbard CANSI7.0 (3)
View the contents of a directoryfinnepower C++Windows6.7 (150)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI6.5 (320)
A function to reverse an integer arrayMajor_Small C or C++ANSI6.5 (343)
Checking for powers of twoWebmaster C or C++ANSI6.4 (260)
a simple clockrichmond caesar CANSI6.4 (393)
One line swap of integersabhilash C or C++ANSI6.3 (12)
This C code uses the merge sort algorithm to sortAbhishek H.Dwivedi C or C++ANSI6.3 (534)
Color header for Windows that integrates with coutSang-drax C++Windows6.2 (198)
A game setup for DirectXPaul D C or C++ANSI6.2 (219)
Three ways to do a swapDavid Nielsen C or C++ANSI6.1 (302)
GotoXYStack Overflow C*nix6.1 (306)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI6.0 (156)
Template Calculatorprog-bman C++ANSI6.0 (263)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI5.9 (190)
euler approximation methoderic mbakop C or C++ANSI5.8 (245)
Next 30

Add a snippet!