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 example for using thousand separator (,)Ali Nawkhas Murad C++ANSI5.9 (63)
Simple linked list implementationyzb3 CANSI5.8 (92)
Simple Windows Socket Server ExampleJahan Addison C++Windows5.8 (95)
GetLastError error lookup toolKen Fitlike CWindows5.8 (185)
This C code recursively sorts an array of upto 20Abhishek H.Dwivedi C or C++ANSI5.8 (211)
Calculates 1 variable statisticsPaul Kennedy C++ANSI5.8 (9)
similar to gotoxy; minimal screen control for wyseMike Kinney C or C++ANSI5.8 (156)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (197)
Pascal's TriangleAli Nawkhas Murad C++ANSI5.8 (139)
An example of Exception HandlingAli Nawkhas Murad C++ANSI5.7 (66)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.7 (133)
View the format of IEEE 754 floating point numbersAli Nawkhas Murad C++ANSI5.7 (116)
Simple swapping heapsortyzb3 C or C++ANSI5.7 (124)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.6 (238)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI5.6 (74)
Quick-sort using vector and iterator in STLJianbao Tao 5.6 (9)
simple StopWatch with roundtrip timeNickMa 5.6 (9)
Palindrome FunctionJason Weeks 5.6 (9)
String FunctionsDominic Vonk 5.6 (9)
String FunctionsDominic Vonk 5.6 (9)
A portable card deck class with shufflingSlyMaelstrom C++ANSI5.6 (9)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI5.5 (119)
Distanceprog-bman C++ANSI5.5 (184)
Failproof xor (en/de)cryptionyzb3 CANSI5.5 (113)
Pascals Triangle Using Combination Function of IndicesSHINE AIYYAPPAN CANSI5.4 (121)
Macro to swap nibble of BYTET Sailesh C or C++ANSI5.4 (10)
Templated queue classAli Nawkhas Murad C++ANSI5.4 (112)
Simple integer binary search example source codeSyed Rafey Husain C or C++ANSI5.3 (6)
Integer subset generatortreenef C++ANSI5.3 (10)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.3 (11)
Next 30
Previous 30

Add a snippet!