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 (405)
Integer subset generatortreenef C++ANSI6.1 (50)
Useful string functionsyzb3 CANSI6.0 (217)
Templated queue classAli Nawkhas Murad C++ANSI6.0 (194)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI6.0 (190)
Template Calculatorprog-bman C++ANSI5.9 (478)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.9 (599)
Count number of bits in a numberNaren Bala C or C++ANSI5.9 (60)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.9 (211)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (309)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.8 (297)
binary addition using stack in STLanmol C++ANSI5.8 (169)
Checking for powers of twoWebmaster C or C++ANSI5.8 (381)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.7 (199)
Generate a spiral matrix for n elementsRaza C or C++ANSI5.7 (145)
Example of polymorphismAli Nawkhas Murad C++ANSI5.7 (260)
GotoXYStack Overflow C*nix5.7 (496)
An example use of a function pointerJayesh C++ANSI5.7 (107)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.7 (254)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI5.7 (249)
Word wrap functionSean Hubbard CANSI5.6 (234)
Distanceprog-bman C++ANSI5.6 (239)
Another merge sort of integer listManoj CANSI5.6 (90)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (415)
A singly linked list with a sentinel implementationyzb3 CANSI5.6 (63)
Permutation GeneratorTreenef C++ANSI5.6 (527)
Simple linked list implementationyzb3 CANSI5.6 (178)
One line swap of integersabhilash C or C++ANSI5.6 (249)
euler approximation methoderic mbakop C or C++ANSI5.6 (329)
Color header for Windows that integrates with coutSang-drax C++Windows5.5 (308)
Next 30
Previous 30