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 (639)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI5.5 (230)
Checking for powers of twoWebmaster C or C++ANSI5.7 (332)
Simple integer binary search example source codeSyed Rafey Husain C or C++ANSI2.3 (33)
euler approximation methoderic mbakop C or C++ANSI5.4 (281)
Permutation GeneratorTreenef C++ANSI5.6 (487)
binary addition using stack in STLanmol C++ANSI5.0 (101)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.7 (152)
Simple example for using thousand separator (,)Ali Nawkhas Murad C++ANSI4.8 (96)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.5 (135)
ASCII table generatorAbdul Haseeb Mir C++ANSI6.5 (496)
An example of simple stack using linked lists.Ali Nawkhas Murad C++ANSI6.4 (480)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI5.5 (454)
Template Calculatorprog-bman C++ANSI5.4 (341)
Distanceprog-bman C++ANSI5.4 (189)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.3 (138)
View the contents of a directoryfinnepower C++Windows5.5 (209)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI4.9 (104)
View the format of IEEE 754 floating point numbersAli Nawkhas Murad C++ANSI6.5 (469)
Example of polymorphismAli Nawkhas Murad C++ANSI5.6 (210)
Templated queue classAli Nawkhas Murad C++ANSI5.7 (128)
Calandar generator printing a full calendar for any yearJoe C++ANSI6.1 (280)
A portable card deck class with shufflingSlyMaelstrom C++ANSI6.8 (398)
Integer subset generatortreenef C++ANSI4.9 (11)
Print variables with file and line number for debuggingmike lear C++ANSI2.6 (37)
An example use of a function pointerJayesh C++ANSI3.6 (43)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI6.6 (452)
Function pointer to member function of classselvam C++ANSI4 (40)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI5.2 (113)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.4 (192)
Next 30
Previous 30

Add a snippet!