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 (399)
Integer subset generatortreenef C++ANSI6.0 (49)
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 (187)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.9 (593)
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 (442)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (303)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.8 (197)
Checking for powers of twoWebmaster C or C++ANSI5.7 (376)
Example of polymorphismAli Nawkhas Murad C++ANSI5.7 (259)
Generate a spiral matrix for n elementsRaza C or C++ANSI5.7 (144)
GotoXYStack Overflow C*nix5.7 (491)
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)
One line swap of integersabhilash C or C++ANSI5.5 (247)
An example use of a function pointerJayesh C++ANSI5.5 (102)
Simple linked list implementationyzb3 CANSI5.5 (175)
Word wrap functionSean Hubbard CANSI5.5 (223)
Simple Windows Socket Server ExampleJahan Addison C++Windows5.5 (194)
This C code uses the merge sort algorithm to sortAbhishek H.Dwivedi C or C++ANSI5.5 (709)
View the contents of a directoryfinnepower C++Windows5.5 (243)
Next 30
Previous 30