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)
this one is better because a potential overflow (of the + operation) is avoided 8.8 (271)
ASCII table generatorAbdul Haseeb Mir C++ANSI7.7 (334)
This is Trigonometry Table made AlhamdulillahAbdul Haseeb Mir CWindows8.2 (260)
One line swap of integersabhilash C or C++ANSI5.2 (185)
This C code recursively sorts an array of upto 20Abhishek H.Dwivedi C or C++ANSI5.3 (235)
This C code uses the merge sort algorithm to sortAbhishek H.Dwivedi C or C++ANSI5.5 (667)
This C code assigns codes to a maximum of 10 charsAbhishek H.Dwivedi C or C++Windows2.9 (33)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.0 (157)
friend function exampleAli Nawkhas Murad C++ANSI8.0 (296)
The standard ASCII table generator.Ali Nawkhas Murad C++ANSI7.8 (328)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.7 (148)
An example of simple stack using linked lists.Ali Nawkhas Murad C++ANSI7.7 (342)
Three Dimension Coordinate Systems ConverterAli Nawkhas Murad C++ANSI5.3 (106)
Templated stack class Ali Nawkhas Murad C++ANSI7.8 (329)
Pascal's TriangleAli Nawkhas Murad C++ANSI7.4 (391)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI5.5 (121)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI4.9 (100)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI5.0 (103)
An example of Exception HandlingAli Nawkhas Murad C++ANSI4.5 (90)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI4.9 (101)
View the format of IEEE 754 floating point numbersAli Nawkhas Murad C++ANSI7.9 (344)
Example of polymorphismAli Nawkhas Murad C++ANSI5.4 (174)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.2 (117)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.6 (137)
Simple example for using thousand separator (,)Ali Nawkhas Murad C++ANSI4.5 (87)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.2 (108)
Templated queue classAli Nawkhas Murad C++ANSI5.4 (112)
Short program to print Hello World! without semicolonAli Nawkhas Murad 8.8 (271)
binary addition using stack in STLanmol C++ANSI4.9 (96)
code to shut a computer with windows XPbenn mutisya 8.8 (271)
Next 30

Add a snippet!