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)
Permutation GeneratorTreenef C++ANSI7.4 (322)
Print variables with file and line number for debuggingmike lear C++ANSI6.2 (10)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI6.2 (168)
Shorter version of gotoxyNedeljko CLinux8.1 (31)
similar to gotoxy; minimal screen control for wyseMike Kinney C or C++ANSI5.8 (156)
Simple example for using thousand separator (,)Ali Murad C++ANSI8.7 (32)
Simple integer binary search example source codeSyed Rafey Husain C or C++ANSI5.3 (6)
Simple linked list implementationyzb3 CANSI8.5 (45)
Simple swapping heapsortyzb3 C or C++ANSI8.7 (64)
Simple Windows Socket Server ExampleJahan Addison C++Windows6.5 (29)
Singly linked list - insert, remove, add, countGirish Amara CANSI7.4 (202)
string to bitstring, bitstring to stringEsa Karjalainen CANSI7.1 (16)
Template Calculatorprog-bman C++ANSI6.1 (274)
Templated queue classAli Murad C++ANSI8.6 (53)
Templated stack class Ali Murad C++ANSI8.7 (46)
The standard ASCII table generator.Ali Murad C++ANSI8.9 (44)
This C code assigns codes to a maximum of 10 charsAbhishek H.Dwivedi C or C++Windows7.4 (5)
This C code recursively sorts an array of upto 20Abhishek H.Dwivedi C or C++ANSI5.7 (207)
This C code uses the merge sort algorithm to sortAbhishek H.Dwivedi C or C++ANSI6.3 (564)
This is Trigonometry Table made AlhamdulillahAbdul Haseeb Mir CWindows6.6 (5)
Three Dimension Coordinate Systems ConverterAli Murad C++ANSI8.9 (22)
Three ways to do a swapDavid Nielsen C or C++ANSI6.3 (317)
useful macros, functions and tricksyzb3 CANSI8.8 (42)
Useful string functionsyzb3 CANSI8.4 (59)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.7 (8)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.8 (133)
View the contents of a directoryfinnepower C++Windows6.9 (159)
View the format of IEEE 754 floating point numbersAli Murad C++ANSI9.0 (50)
Word wrap functionSean Hubbard CANSI8.6 (50)
xor (en/de)cryption using a key fileyzb3 CANSI8.8 (41)
Next 30
Previous 30

Add a snippet!