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++ANSI2.9 (37)
Create a new file under linuxChol Nhial 8.8 (271)
Integer Partitions from 1 to NChristopher Brown 8.8 (271)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.7 (241)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.2 (162)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (372)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI5.5 (196)
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++Multiple4.1 (43)
String FunctionsDominic Vonk 8.8 (270)
String FunctionsDominic Vonk 8.8 (270)
Convert an integer into binary representationElabed Soufiane CANSI3.2 (42)
euler approximation methoderic mbakop C or C++ANSI5.5 (280)
string to bitstring, bitstring to stringEsa Karjalainen CANSI3.9 (43)
View the contents of a directoryfinnepower C++Windows5.5 (208)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI4.8 (96)
Find the minimum distance between two linesGiacomo C or C++ANSI2.9 (35)
Singly linked list - insert, remove, add, countGirish Amara CANSI7.2 (992)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows4.9 (95)
Simple Windows Socket Server ExampleJahan Addison C++Windows4.8 (119)
Dynamically Allocating a Multidimensional ArrayJared Hendrickson CANSI2.5 (34)
Palindrome FunctionJason Weeks 8.8 (270)
An example use of a function pointerJayesh C++ANSI3.3 (40)
Without semicolon print the statement.Jeevanrao 8.8 (271)
Without semicolon print the statement.Jeevanrao 8.8 (271)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.3 (221)
Quick-sort using vector and iterator in STLJianbao Tao 8.8 (270)
Calandar generator printing a full calendar for any yearJoe C++ANSI5.3 (73)
Implementing a directory listing on LinuxJoshith C*nix2.8 (36)
GetLastError error lookup toolKen Fitlike CWindows5.2 (209)
Next 30
Previous 30

Add a snippet!