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 portable card deck class with shufflingSlyMaelstrom C++ANSI5.6 (9)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.5 (132)
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)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI5.5 (196)
a simple clockrichmond caesar CANSI5.5 (537)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI5.5 (119)
euler approximation methoderic mbakop C or C++ANSI5.5 (280)
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 (279)
Useful string functionsyzb3 CANSI5.4 (132)
Macro to swap nibble of BYTET Sailesh C or C++ANSI5.4 (10)
Example of polymorphismAli Nawkhas Murad C++ANSI5.4 (172)
Templated queue classAli Nawkhas Murad C++ANSI5.4 (112)
Color header for Windows that integrates with coutSang-drax C++Windows5.4 (255)
Template Calculatorprog-bman C++ANSI5.3 (325)
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 (235)
Integer subset generatortreenef C++ANSI5.3 (10)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.3 (11)
Three Dimension Coordinate Systems ConverterAli Nawkhas Murad C++ANSI5.3 (106)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.3 (221)
Word wrap functionSean Hubbard CANSI5.3 (111)
GetLastError error lookup toolKen Fitlike CWindows5.2 (209)
One line swap of integersabhilash C or C++ANSI5.2 (185)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.2 (162)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.2 (116)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI5.2 (57)
Next 30
Previous 30

Add a snippet!