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.9 (835)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI6.2 (620)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.9 (599)
A game setup for DirectXPaul D C or C++ANSI6.1 (405)
A portable card deck class with shufflingSlyMaelstrom C++ANSI7.1 (527)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI6.2 (328)
a simple clockrichmond caesar CANSI6.4 (1091)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.7 (254)
A simple example of hashtableAli Nawkhas Murad C++ANSI5.7 (199)
A singly linked list with a sentinel implementationyzb3 CANSI5.6 (63)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (309)
An example of Exception HandlingAli Nawkhas Murad C++ANSI5.3 (139)
An example of simple priority queue using linked lists.Ali Nawkhas Murad C++ANSI5.5 (186)
An example of simple stack using linked lists.Ali Nawkhas Murad C++ANSI6.4 (532)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI5.4 (139)
An example use of a function pointerJayesh C++ANSI5.7 (107)
Another merge sort of integer listManoj CANSI5.6 (90)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI5.4 (100)
ASCII table generatorAbdul Haseeb Mir C++ANSI6.7 (603)
binary addition using stack in STLanmol C++ANSI5.8 (169)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI6.3 (301)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI6.7 (509)
Calandar generator printing a full calendar for any yearJoe C++ANSI6.6 (437)
Calculates 1 variable statisticsPaul Kennedy C++ANSI4.9 (84)
Calculates the closest point to a segmentAdri�n Deccico C or C++ANSI5.3 (206)
Checking for powers of twoWebmaster C or C++ANSI5.8 (381)
Color header for Windows that integrates with coutSang-drax C++Windows5.5 (308)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.9 (211)
Convert an integer into binary representationElabed Soufiane CANSI5.0 (91)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows5.4 (147)
Next 30