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)
Templated queue classAli Nawkhas Murad C++ANSI5.7 (126)
GotoXYStack Overflow C*nix5.7 (442)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (373)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.6 (146)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI5.6 (166)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.6 (133)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.6 (12)
Permutation GeneratorTreenef C++ANSI5.6 (486)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI5.6 (229)
Example of polymorphismAli Nawkhas Murad C++ANSI5.6 (208)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI5.5 (200)
useful macros, functions and tricksyzb3 CANSI5.5 (115)
View the contents of a directoryfinnepower C++Windows5.5 (208)
This C code uses the merge sort algorithm to sortAbhishek H.Dwivedi C or C++ANSI5.5 (670)
xor (en/de)cryption using a key fileyzb3 CANSI5.5 (116)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI5.5 (452)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.5 (480)
euler approximation methoderic mbakop C or C++ANSI5.5 (280)
Distanceprog-bman C++ANSI5.5 (187)
Simple linked list implementationyzb3 CANSI5.5 (137)
Template Calculatorprog-bman C++ANSI5.4 (336)
A game setup for DirectXPaul D C or C++ANSI5.4 (286)
One line swap of integersabhilash C or C++ANSI5.4 (201)
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)
Three Dimension Coordinate Systems ConverterAli Nawkhas Murad C++ANSI5.3 (109)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.3 (186)
Integer subset generatortreenef C++ANSI5.3 (10)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.3 (137)
Next 30
Previous 30

Add a snippet!