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.8 (578)
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++ANSI5.9 (7)
euler approximation methoderic mbakop C or C++ANSI5.5 (280)
Permutation GeneratorTreenef C++ANSI5.8 (465)
binary addition using stack in STLanmol C++ANSI5.1 (100)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.7 (143)
Simple example for using thousand separator (,)Ali Nawkhas Murad C++ANSI4.6 (91)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.7 (125)
ASCII table generatorAbdul Haseeb Mir C++ANSI7.1 (433)
An example of simple stack using linked lists.Ali Nawkhas Murad C++ANSI7.0 (423)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI5.5 (452)
Template Calculatorprog-bman C++ANSI5.4 (334)
Distanceprog-bman C++ANSI5.5 (187)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.2 (135)
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++ANSI7.2 (417)
Example of polymorphismAli Nawkhas Murad C++ANSI5.6 (202)
Templated queue classAli Nawkhas Murad C++ANSI5.6 (122)
Calandar generator printing a full calendar for any yearJoe C++ANSI7.1 (208)
A portable card deck class with shufflingSlyMaelstrom C++ANSI7.6 (343)
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++ANSI7.3 (396)
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.8 (165)
Next 30
Previous 30

Add a snippet!