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 (625)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI5.5 (452)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.5 (478)
A game setup for DirectXPaul D C or C++ANSI5.4 (285)
A portable card deck class with shufflingSlyMaelstrom C++ANSI6.8 (391)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI5.6 (229)
a simple clockrichmond caesar CANSI5.7 (674)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.3 (186)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.7 (145)
A singly linked list with a sentinel implementationyzb3 CANSI4.9 (21)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.3 (228)
An example of Exception HandlingAli Nawkhas Murad C++ANSI4.6 (92)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.2 (135)
An example of simple stack using linked lists.Ali Nawkhas Murad C++ANSI6.4 (470)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI5.0 (103)
An example use of a function pointerJayesh C++ANSI3.6 (42)
Another merge sort of integer listManoj CANSI4.2 (46)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI4.5 (52)
ASCII table generatorAbdul Haseeb Mir C++ANSI6.5 (482)
binary addition using stack in STLanmol C++ANSI5.1 (100)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI5.5 (159)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI6.6 (444)
Calandar generator printing a full calendar for any yearJoe C++ANSI6.0 (258)
Calculates 1 variable statisticsPaul Kennedy C++ANSI2.3 (33)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.0 (158)
Checking for powers of twoWebmaster C or C++ANSI5.7 (323)
Color header for Windows that integrates with coutSang-drax C++Windows5.4 (256)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.6 (129)
Convert an integer into binary representationElabed Soufiane CANSI3.4 (43)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows5.0 (96)
Next 30

Add a snippet!