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)
This C code uses the merge sort algorithm to sortAbhishek H.Dwivedi C or C++ANSI5.5 (710)
View the contents of a directoryfinnepower C++Windows5.5 (244)
useful macros, functions and tricksyzb3 CANSI5.5 (153)
Color header for Windows that integrates with coutSang-drax C++Windows5.5 (304)
Another merge sort of integer listManoj CANSI5.5 (86)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.4 (216)
xor (en/de)cryption using a key fileyzb3 CANSI5.4 (151)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.4 (182)
A singly linked list with a sentinel implementationyzb3 CANSI5.4 (60)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI5.4 (152)
string to bitstring, bitstring to stringEsa Karjalainen CANSI5.4 (86)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI5.4 (101)
GetLastError error lookup toolKen Fitlike CWindows5.4 (245)
This C code recursively sorts an array of upto 20Abhishek H.Dwivedi C or C++ANSI5.4 (273)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.3 (50)
Macro to swap nibble of BYTET Sailesh C or C++ANSI5.3 (95)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI5.3 (135)
similar to gotoxy; minimal screen control for wyseMike Kinney C or C++ANSI5.3 (215)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI5.3 (138)
Simple swapping heapsortyzb3 C or C++ANSI5.3 (195)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows5.3 (143)
Failproof xor (en/de)cryptionyzb3 CANSI5.3 (196)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.2 (202)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI5.2 (143)
how to implement strlwr in CSyed Rafey Husain C or C++ANSI5.2 (91)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI5.2 (96)
Simple example for using thousand separator (,)Ali Nawkhas Murad C++ANSI5.2 (134)
An example of Exception HandlingAli Nawkhas Murad C++ANSI5.2 (134)
Function pointer to member function of classselvam C++ANSI5.1 (75)
Implementing a directory listing on LinuxJoshith C*nix5.1 (89)
Next 30
Previous 30