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.2 (228)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI6.7 (347)
A function to reverse an integer arrayMajor_Small C or C++ANSI6.6 (361)
A game setup for DirectXPaul D C or C++ANSI6.3 (231)
A portable card deck class with shufflingSlyMaelstrom C++ANSI5.6 (9)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI6.1 (203)
a simple clockrichmond caesar CANSI6.5 (431)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI7.8 (91)
A simple example of hashtableAli Nawkhas Murad C++ANSI8.1 (78)
A singly linked list with a sentinel implementationyzb3 CANSI4.9 (21)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (197)
An example of Exception HandlingAli Nawkhas Murad C++ANSI8.4 (42)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI8.1 (66)
An example of simple stack using linked lists.Ali Nawkhas Murad C++ANSI7.9 (66)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI8.4 (53)
An example use of a function pointerJayesh C++ANSI6.9 (15)
Another merge sort of integer listManoj CANSI6.3 (11)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI7.2 (25)
ASCII table generatorAbdul Haseeb Mir C++ANSI8.0 (55)
binary addition using stack in STLanmol C++ANSI8.8 (48)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI6.6 (36)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI7.8 (50)
Calandar generator printing a full calendar for any yearJoe C++ANSI7.2 (44)
Calculates 1 variable statisticsPaul Kennedy C++ANSI5.8 (9)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.7 (133)
Checking for powers of twoWebmaster C or C++ANSI6.5 (270)
code to shut a computer with windows XPbenn mutisya 5.6 (9)
Color header for Windows that integrates with coutSang-drax C++Windows6.4 (207)
Conversions between number systemsAli Nawkhas Murad C++ANSI8.5 (57)
Convert an integer into binary representationElabed Soufiane CANSI6.5 (17)
Next 30

Add a snippet!