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 short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI6.2 (305)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI6.2 (586)
A game setup for DirectXPaul D C or C++ANSI6.1 (378)
Templated queue classAli Nawkhas Murad C++ANSI6.1 (172)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI6.1 (169)
Useful string functionsyzb3 CANSI6.1 (191)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.9 (570)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.9 (174)
A singly linked list with a sentinel implementationyzb3 CANSI5.9 (40)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.9 (276)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (283)
Generate a spiral matrix for n elementsRaza C or C++ANSI5.8 (123)
Checking for powers of twoWebmaster C or C++ANSI5.8 (357)
Template Calculatorprog-bman C++ANSI5.8 (421)
Example of polymorphismAli Nawkhas Murad C++ANSI5.8 (238)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.8 (174)
binary addition using stack in STLanmol C++ANSI5.7 (141)
GotoXYStack Overflow C*nix5.7 (470)
An example use of a function pointerJayesh C++ANSI5.7 (81)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI5.7 (223)
One line swap of integersabhilash C or C++ANSI5.6 (231)
Simple linked list implementationyzb3 CANSI5.6 (162)
Another merge sort of integer listManoj CANSI5.6 (78)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.6 (226)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (390)
Simple Windows Socket Server ExampleJahan Addison C++Windows5.6 (174)
Permutation GeneratorTreenef C++ANSI5.6 (506)
Distanceprog-bman C++ANSI5.6 (212)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.6 (29)
euler approximation methoderic mbakop C or C++ANSI5.6 (305)
Next 30
Previous 30