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)
Merge sort of an integer listBibhubrata Narendra C or C++ANSI6.3 (12)
Create a new file under linuxChol Nhial 5.3 (8)
Integer Partitions from 1 to NChristopher Brown 5.3 (8)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.6 (238)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.9 (137)
Three ways to do a swapDavid Nielsen C or C++ANSI6.3 (319)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI6.1 (171)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.3 (11)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple7.9 (17)
String FunctionsDominic Vonk 4.7 (7)
String FunctionsDominic Vonk 4.7 (7)
Convert an integer into binary representationElabed Soufiane CANSI6.5 (17)
euler approximation methoderic mbakop C or C++ANSI5.9 (256)
string to bitstring, bitstring to stringEsa Karjalainen CANSI7.4 (18)
View the contents of a directoryfinnepower C++Windows6.9 (160)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI8.7 (48)
Find the minimum distance between two linesGiacomo C or C++ANSI7.2 (11)
Singly linked list - insert, remove, add, countGirish Amara CANSI7.6 (564)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows9.0 (46)
Simple Windows Socket Server ExampleJahan Addison C++Windows7.4 (64)
Dynamically Allocating a Multidimensional ArrayJared Hendrickson CANSI6.2 (10)
Palindrome FunctionJason Weeks 4.7 (7)
An example use of a function pointerJayesh C++ANSI6.9 (15)
Without semicolon print the statement.Jeevanrao 5.3 (8)
Without semicolon print the statement.Jeevanrao 5.3 (8)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (196)
Quick-sort using vector and iterator in STLJianbao Tao 4.7 (7)
Calandar generator printing a full calendar for any yearJoe C++ANSI7.1 (43)
Implementing a directory listing on LinuxJoshith C*nix6.3 (12)
GetLastError error lookup toolKen Fitlike CWindows5.8 (185)
Next 30
Previous 30

Add a snippet!