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)
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.3 (166)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (373)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI5.5 (200)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.6 (12)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple5.1 (60)
String FunctionsDominic Vonk 8.1 (440)
Convert an integer into binary representationElabed Soufiane CANSI3.4 (43)
euler approximation methoderic mbakop C or C++ANSI5.5 (280)
string to bitstring, bitstring to stringEsa Karjalainen CANSI4.8 (53)
View the contents of a directoryfinnepower C++Windows5.5 (208)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI4.9 (97)
Find the minimum distance between two linesGiacomo C or C++ANSI2.9 (35)
Singly linked list - insert, remove, add, countGirish Amara CANSI7.3 (1725)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows5.0 (96)
Simple Windows Socket Server ExampleJahan Addison C++Windows5.2 (139)
Dynamically Allocating a Multidimensional ArrayJared Hendrickson CANSI2.5 (35)
Palindrome FunctionJason Weeks 8.1 (440)
An example use of a function pointerJayesh C++ANSI3.6 (42)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.3 (228)
Quick-sort using vector and iterator in STLJianbao Tao 8.1 (440)
Calandar generator printing a full calendar for any yearJoe C++ANSI7.1 (207)
Implementing a directory listing on LinuxJoshith C*nix4.1 (46)
GetLastError error lookup toolKen Fitlike CWindows5.2 (209)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI4.5 (52)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI5.6 (229)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.7 (453)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI5.5 (452)
Another merge sort of integer listManoj CANSI4.2 (46)
Output console text with type-writer effect.Michael Brandon Miller 8.1 (441)
Next 30
Previous 30

Add a snippet!