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)
A game setup for DirectXPaul D C or C++ANSI6.1 (398)
Integer subset generatortreenef C++ANSI6.0 (48)
Useful string functionsyzb3 CANSI6.0 (214)
Templated queue classAli Nawkhas Murad C++ANSI6.0 (192)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI5.9 (185)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.9 (593)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.8 (195)
Count number of bits in a numberNaren Bala C or C++ANSI5.8 (58)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.8 (296)
Template Calculatorprog-bman C++ANSI5.8 (437)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (302)
Checking for powers of twoWebmaster C or C++ANSI5.7 (376)
GotoXYStack Overflow C*nix5.7 (490)
Example of polymorphismAli Nawkhas Murad C++ANSI5.7 (259)
Generate a spiral matrix for n elementsRaza C or C++ANSI5.7 (143)
binary addition using stack in STLanmol C++ANSI5.7 (163)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.6 (194)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI5.6 (245)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (413)
Distanceprog-bman C++ANSI5.6 (236)
Permutation GeneratorTreenef C++ANSI5.6 (526)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.6 (247)
euler approximation methoderic mbakop C or C++ANSI5.5 (328)
An example use of a function pointerJayesh C++ANSI5.5 (102)
One line swap of integersabhilash C or C++ANSI5.5 (246)
Simple linked list implementationyzb3 CANSI5.5 (175)
This C code uses the merge sort algorithm to sortAbhishek H.Dwivedi C or C++ANSI5.5 (709)
Simple Windows Socket Server ExampleJahan Addison C++Windows5.5 (193)
View the contents of a directoryfinnepower C++Windows5.5 (243)
Color header for Windows that integrates with coutSang-drax C++Windows5.5 (303)
Next 30
Previous 30