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)
Knuth-Morris-Pratt (KMP) String Search AlgorithmSyed Rafey Husain C or C++ANSI9.8 (276)
View the format of IEEE 754 floating point numbersAli Murad C++ANSI9.0 (50)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI9.0 (34)
Failproof xor (en/de)cryptionyzb3 CANSI9.0 (53)
An example of Exception HandlingAli Murad C++ANSI8.9 (37)
Pascals Triangle Using Combination Function of IndicesSHINE AIYYAPPAN CANSI8.9 (45)
Three Dimension Coordinate Systems ConverterAli Murad C++ANSI8.9 (22)
The standard ASCII table generator.Ali Murad C++ANSI8.9 (44)
xor (en/de)cryption using a key fileyzb3 CANSI8.8 (41)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows8.8 (38)
binary addition using stack in STLanmol C++ANSI8.8 (37)
useful macros, functions and tricksyzb3 CANSI8.8 (42)
Examples of dynamic multidimensional arraysAli Murad C++ANSI8.8 (53)
Templated stack class Ali Murad C++ANSI8.7 (46)
Simple swapping heapsortyzb3 C or C++ANSI8.7 (64)
Initial values for static multidimensional arrayAli Murad C or C++ANSI8.7 (48)
ASCII table generatorAbdul Haseeb Mir C++ANSI8.7 (27)
An example of using the same variable name in different scopesAli Murad C++ANSI8.7 (50)
Simple example for using thousand separator (,)Ali Murad C++ANSI8.7 (32)
Pascal's TriangleAli Murad C++ANSI8.6 (63)
Word wrap functionSean Hubbard CANSI8.6 (50)
Find size and storage capacity of primitive data typesAli Murad C++ANSI8.6 (47)
Conversions between number systemsAli Murad C++ANSI8.6 (42)
Templated queue classAli Murad C++ANSI8.6 (53)
Example of polymorphismAli Murad C++ANSI8.6 (55)
Simple linked list implementationyzb3 CANSI8.5 (45)
An example of simple priority queue using linked lists.Ali Murad C++ANSI8.4 (45)
Useful string functionsyzb3 CANSI8.4 (59)
A simple example of hashtableAli Murad C++ANSI8.3 (52)
An example of simple stack using linked lists.Ali Murad C++ANSI8.3 (44)
Next 30

Add a snippet!