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)
Simple swapping heapsortyzb3 C or C++ANSI5.9 (131)
Permutation GeneratorTreenef C++ANSI5.7 (460)
GotoXYStack Overflow C*nix5.7 (396)
Calandar generator printing a full calendar for any yearJoe C++ANSI5.7 (90)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.7 (443)
Checking for powers of twoWebmaster C or C++ANSI5.7 (323)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.7 (241)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.6 (138)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.6 (152)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (372)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.6 (12)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI5.5 (228)
View the contents of a directoryfinnepower C++Windows5.5 (208)
This C code uses the merge sort algorithm to sortAbhishek H.Dwivedi C or C++ANSI5.5 (667)
a simple clockrichmond caesar CANSI5.5 (543)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI5.5 (197)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI5.5 (122)
Useful string functionsyzb3 CANSI5.5 (136)
euler approximation methoderic mbakop C or C++ANSI5.5 (280)
Example of polymorphismAli Nawkhas Murad C++ANSI5.5 (176)
Distanceprog-bman C++ANSI5.5 (184)
Failproof xor (en/de)cryptionyzb3 CANSI5.5 (113)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI5.5 (444)
A game setup for DirectXPaul D C or C++ANSI5.4 (280)
Templated queue classAli Nawkhas Murad C++ANSI5.4 (113)
Macro to swap nibble of BYTET Sailesh C or C++ANSI5.4 (10)
Color header for Windows that integrates with coutSang-drax C++Windows5.4 (255)
Template Calculatorprog-bman C++ANSI5.3 (327)
Simple integer binary search example source codeSyed Rafey Husain C or C++ANSI5.3 (6)
This C code recursively sorts an array of upto 20Abhishek H.Dwivedi C or C++ANSI5.3 (236)
Next 30
Previous 30

Add a snippet!