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)
Shorter version of gotoxyNedeljko CLinux5.5 (102)
Three Dimension Coordinate Systems ConverterAli Nawkhas Murad C++ANSI5.5 (159)
Simple Windows Socket Server ExampleJahan Addison C++Windows5.5 (197)
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)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.5 (186)
useful macros, functions and tricksyzb3 CANSI5.5 (153)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI5.5 (103)
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 using the same variable name in different scopesAli Nawkhas Murad C++ANSI5.4 (139)
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)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows5.4 (147)
Macro to swap nibble of BYTET Sailesh C or C++ANSI5.4 (97)
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)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI5.4 (100)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.3 (50)
how to implement strlwr in CSyed Rafey Husain C or C++ANSI5.3 (94)
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)
Calculates the closest point to a segmentAdri´┐Żn Deccico C or C++ANSI5.3 (206)
An example of Exception HandlingAli Nawkhas Murad C++ANSI5.3 (139)
Failproof xor (en/de)cryptionyzb3 CANSI5.3 (196)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI5.2 (144)
Simple example for using thousand separator (,)Ali 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