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)
Templated stack class Ali Nawkhas Murad C++ANSI9.6 (4824)
Create a new file under linuxChol Nhial 7.4 (579)
Menu driven program in c programmingcampus 7.4 (683)
String FunctionsDominic Vonk 7.4 (570)
Palindrome FunctionJason Weeks 7.4 (552)
simple StopWatch with roundtrip timeNickMa 7.4 (557)
Eventhandling macro for classesToolsDevler 7.3 (547)
Integer Partitions from 1 to NChristopher Brown 7.3 (545)
Output console text with type-writer effect.Michael Brandon Miller 7.3 (537)
Tic-TacToeptrs 7.3 (571)
Quick-sort using vector and iterator in STLJianbao Tao 7.3 (545)
Singly linked list - insert, remove, add, countGirish Amara CANSI7.3 (2516)
A portable card deck class with shufflingSlyMaelstrom C++ANSI7.0 (514)
A code template for OpenGL / GLUTPerspective C or C++ANSI6.8 (820)
ASCII table generatorAbdul Haseeb Mir C++ANSI6.7 (584)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI6.6 (501)
Calandar generator printing a full calendar for any yearJoe C++ANSI6.6 (422)
Knuth-Morris-Pratt (KMP) String Search AlgorithmSyed Rafey Husain C or C++ANSI6.6 (922)
friend function exampleAli Nawkhas Murad C++ANSI6.5 (475)
View the format of IEEE 754 floating point numbersAli Nawkhas Murad C++ANSI6.5 (508)
The standard ASCII table generator.Ali Nawkhas Murad C++ANSI6.4 (501)
An example of simple stack using linked lists.Ali Nawkhas Murad C++ANSI6.4 (524)
This is Trigonometry Table made AlhamdulillahAbdul Haseeb Mir CWindows6.4 (441)
Pascal's TriangleAli Nawkhas Murad C++ANSI6.3 (586)
a simple clockrichmond caesar CANSI6.3 (1066)
Pascals Triangle Using Combination Function of IndicesSHINE AIYYAPPAN CANSI6.3 (568)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI6.2 (292)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI6.2 (323)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple6.2 (129)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI6.1 (608)
Next 30