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)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.3 (11)
Three Dimension Coordinate Systems ConverterAli Nawkhas Murad C++ANSI5.3 (106)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.3 (221)
Word wrap functionSean Hubbard CANSI5.3 (111)
GetLastError error lookup toolKen Fitlike CWindows5.2 (209)
One line swap of integersabhilash C or C++ANSI5.2 (185)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.2 (108)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.2 (162)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.2 (117)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI5.2 (57)
similar to gotoxy; minimal screen control for wyseMike Kinney C or C++ANSI5.1 (180)
Shorter version of gotoxyNedeljko CLinux5.1 (59)
Count number of bits in a numberNaren Bala C or C++ANSI5.1 (9)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI5.0 (103)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.0 (157)
xor (en/de)cryption using a key fileyzb3 CANSI4.9 (98)
binary addition using stack in STLanmol C++ANSI4.9 (96)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows4.9 (95)
A singly linked list with a sentinel implementationyzb3 CANSI4.9 (21)
Simple linked list implementationyzb3 CANSI4.9 (117)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI4.9 (101)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI4.9 (100)
Simple Windows Socket Server ExampleJahan Addison C++Windows4.8 (119)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI4.8 (96)
useful macros, functions and tricksyzb3 CANSI4.8 (95)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI4.7 (68)
Simple example for using thousand separator (,)Ali Nawkhas Murad C++ANSI4.5 (87)
An example of Exception HandlingAli Nawkhas Murad C++ANSI4.5 (90)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI4.3 (50)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple4.1 (43)
Next 30
Previous 30

Add a snippet!