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)
A code template for OpenGL / GLUTPerspective C or C++ANSI6.4 (626)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI5.6 (229)
Checking for powers of twoWebmaster C or C++ANSI5.7 (323)
Simple integer binary search example source codeSyed Rafey Husain C or C++ANSI2.3 (32)
euler approximation methoderic mbakop C or C++ANSI5.5 (280)
Permutation GeneratorTreenef C++ANSI5.6 (486)
binary addition using stack in STLanmol C++ANSI5.1 (100)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.6 (146)
Simple example for using thousand separator (,)Ali Nawkhas Murad C++ANSI4.6 (91)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.6 (132)
ASCII table generatorAbdul Haseeb Mir C++ANSI6.5 (484)
An example of simple stack using linked lists.Ali Nawkhas Murad C++ANSI6.4 (471)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI5.5 (452)
Template Calculatorprog-bman C++ANSI5.4 (336)
Distanceprog-bman C++ANSI5.5 (187)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.3 (137)
View the contents of a directoryfinnepower C++Windows5.5 (208)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI5.0 (103)
View the format of IEEE 754 floating point numbersAli Nawkhas Murad C++ANSI6.5 (464)
Example of polymorphismAli Nawkhas Murad C++ANSI5.6 (207)
Templated queue classAli Nawkhas Murad C++ANSI5.7 (126)
Calandar generator printing a full calendar for any yearJoe C++ANSI6.0 (262)
A portable card deck class with shufflingSlyMaelstrom C++ANSI6.8 (392)
Integer subset generatortreenef C++ANSI5.3 (10)
Print variables with file and line number for debuggingmike lear C++ANSI2.7 (36)
An example use of a function pointerJayesh C++ANSI3.6 (42)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI6.6 (444)
Function pointer to member function of classselvam C++ANSI4.0 (39)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI5.3 (112)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.3 (186)
Next 30
Previous 30

Add a snippet!