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)
Singly linked list - insert, remove, add, countGirish Amara CANSI7.4 (619)
Knuth-Morris-Pratt (KMP) String Search AlgorithmSyed Rafey Husain C or C++ANSI7.2 (412)
Permutation GeneratorTreenef C++ANSI7.0 (359)
One line swap of integersabhilash C or C++ANSI6.7 (135)
friend function exampleAli Nawkhas Murad C++ANSI6.6 (39)
Checking for powers of twoWebmaster C or C++ANSI6.5 (270)
a simple clockrichmond caesar CANSI6.5 (431)
A simple example of hashtableAli Nawkhas Murad C++ANSI6.4 (103)
Three Dimension Coordinate Systems ConverterAli Nawkhas Murad C++ANSI6.4 (80)
Creating, printing and free linked listsSyed Rafey Husain CANSI6.4 (8)
Color header for Windows that integrates with coutSang-drax C++Windows6.4 (207)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI6.3 (115)
Useful string functionsyzb3 CANSI6.3 (107)
Word wrap functionSean Hubbard CANSI6.3 (85)
A game setup for DirectXPaul D C or C++ANSI6.3 (231)
GotoXYStack Overflow C*nix6.3 (340)
Conversions between number systemsAli Nawkhas Murad C++ANSI6.3 (82)
Templated stack class Ali Nawkhas Murad C++ANSI6.3 (76)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI6.3 (372)
Three ways to do a swapDavid Nielsen C or C++ANSI6.3 (320)
This C code uses the merge sort algorithm to sortAbhishek H.Dwivedi C or C++ANSI6.3 (571)
Another merge sort of integer listManoj CANSI6.3 (11)
A function to reverse an integer arrayMajor_Small C or C++ANSI6.3 (385)
The standard ASCII table generator.Ali Nawkhas Murad C++ANSI6.3 (75)
Implementing a directory listing on LinuxJoshith C*nix6.3 (12)
Merge sort of an integer listBibhubrata Narendra C or C++ANSI6.3 (12)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI6.2 (91)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows6.2 (71)
binary addition using stack in STLanmol C++ANSI6.2 (72)
Convert an integer into binary representationElabed Soufiane CANSI6.2 (18)
Next 30

Add a snippet!