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)
Template Calculatorprog-bman C++ANSI5.4 (332)
Color header for Windows that integrates with coutSang-drax C++Windows5.4 (256)
This C code recursively sorts an array of upto 20Abhishek H.Dwivedi C or C++ANSI5.3 (236)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.3 (166)
Integer subset generatortreenef C++ANSI5.3 (10)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.3 (227)
Three Dimension Coordinate Systems ConverterAli Nawkhas Murad C++ANSI5.3 (108)
GetLastError error lookup toolKen Fitlike CWindows5.2 (209)
Simple Windows Socket Server ExampleJahan Addison C++Windows5.2 (139)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.2 (133)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI5.2 (59)
similar to gotoxy; minimal screen control for wyseMike Kinney C or C++ANSI5.1 (180)
Shorter version of gotoxyNedeljko CLinux5.1 (59)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI5.1 (108)
Generate a spiral matrix for n elementsRaza C or C++ANSI5.1 (69)
Count number of bits in a numberNaren Bala C or C++ANSI5.1 (9)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple5.1 (58)
Simple linked list implementationyzb3 CANSI5.1 (124)
xor (en/de)cryption using a key fileyzb3 CANSI5.0 (103)
binary addition using stack in STLanmol C++ANSI5.0 (98)
useful macros, functions and tricksyzb3 CANSI5.0 (99)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI5.0 (103)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.0 (157)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows5.0 (96)
A singly linked list with a sentinel implementationyzb3 CANSI4.9 (21)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI4.9 (97)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI4.9 (100)
Simple example for using thousand separator (,)Ali Nawkhas Murad C++ANSI4.6 (91)
An example of Exception HandlingAli Nawkhas Murad C++ANSI4.6 (92)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI4.5 (52)
Next 30
Previous 30

Add a snippet!