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++ANSI5.8 (208)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI6.7 (340)
A function to reverse an integer arrayMajor_Small C or C++ANSI6.6 (356)
A game setup for DirectXPaul D C or C++ANSI6.3 (229)
A portable card deck class with shufflingSlyMaelstrom C++ANSI5.0 (8)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI6.0 (199)
a simple clockrichmond caesar CANSI6.4 (416)
A simple double linked list using OOP techniquesAli Murad C++ANSI7.6 (58)
A simple example of hashtableAli Murad C++ANSI8.1 (37)
A singly linked list with a sentinel implementationyzb3 CANSI3.6 (16)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.7 (189)
An example of Exception HandlingAli Murad C++ANSI8.9 (22)
An example of simple priority queue using linked lists.Ali Murad C++ANSI8.1 (29)
An example of simple stack using linked lists.Ali Murad C++ANSI8.1 (27)
An example of using the same variable name in different scopesAli Murad C++ANSI8.5 (35)
An example use of a function pointerJayesh C++ANSI6.1 (9)
Another merge sort of integer listManoj CANSI5.9 (10)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI6.5 (13)
ASCII table generatorAbdul Haseeb Mir C++ANSI8.3 (12)
binary addition using stack in STLanmol C++ANSI8.7 (22)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI6.2 (19)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI7.9 (40)
Calandar generator printing a full calendar for any yearJoe C++ANSI6.5 (19)
Calculates 1 variable statisticsPaul Kennedy C++ANSI5.3 (8)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.7 (132)
Checking for powers of twoWebmaster C or C++ANSI6.4 (266)
Color header for Windows that integrates with coutSang-drax C++Windows6.3 (206)
Conversions between number systemsAli Murad C++ANSI8.3 (27)
Convert an integer into binary representationElabed Soufiane CANSI6.2 (14)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows8.7 (23)
Next 30

Add a snippet!