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)
Pascals Triangle Using Combination Function of IndicesSHINE AIYYAPPAN CANSI6.7 (439)
Simple swapping heapsortyzb3 C or C++ANSI5.9 (134)
Simple integer binary search example source codeSyed Rafey Husain C or C++ANSI5.9 (7)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.8 (163)
Permutation GeneratorTreenef C++ANSI5.8 (465)
GotoXYStack Overflow C*nix5.8 (404)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.7 (449)
a simple clockrichmond caesar CANSI5.7 (608)
Checking for powers of twoWebmaster C or C++ANSI5.7 (323)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.7 (143)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.7 (241)
Useful string functionsyzb3 CANSI5.6 (142)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (373)
Templated queue classAli Nawkhas Murad C++ANSI5.6 (119)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI5.6 (97)
Example of polymorphismAli Nawkhas Murad C++ANSI5.6 (198)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.6 (12)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI5.6 (124)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI5.6 (229)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI5.5 (198)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.5 (121)
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 function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI5.5 (451)
Failproof xor (en/de)cryptionyzb3 CANSI5.5 (117)
euler approximation methoderic mbakop C or C++ANSI5.5 (280)
Distanceprog-bman C++ANSI5.5 (187)
A game setup for DirectXPaul D C or C++ANSI5.4 (283)
Word wrap functionSean Hubbard CANSI5.4 (118)
One line swap of integersabhilash C or C++ANSI5.4 (199)
Next 30
Previous 30

Add a snippet!