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)
Integer subset generatortreenef C++ANSI6.1 (50)
A game setup for DirectXPaul D C or C++ANSI6.1 (401)
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 (188)
Count number of bits in a numberNaren Bala C or C++ANSI5.9 (60)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.9 (594)
Template Calculatorprog-bman C++ANSI5.9 (468)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.8 (204)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.8 (297)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (304)
Checking for powers of twoWebmaster C or C++ANSI5.7 (377)
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 (494)
binary addition using stack in STLanmol C++ANSI5.7 (164)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.7 (195)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI5.7 (249)
An example use of a function pointerJayesh C++ANSI5.6 (104)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (415)
Distanceprog-bman C++ANSI5.6 (237)
Word wrap functionSean Hubbard CANSI5.6 (231)
Permutation GeneratorTreenef C++ANSI5.6 (527)
One line swap of integersabhilash C or C++ANSI5.6 (249)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.6 (248)
euler approximation methoderic mbakop C or C++ANSI5.6 (329)
Simple linked list implementationyzb3 CANSI5.5 (176)
Shorter version of gotoxyNedeljko CLinux5.5 (102)
Three Dimension Coordinate Systems ConverterAli Nawkhas Murad C++ANSI5.5 (159)
Simple Windows Socket Server ExampleJahan Addison C++Windows5.5 (197)
Next 30
Previous 30