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)
Create a new file under linuxChol Nhial 8.1 (441)
simple StopWatch with roundtrip timeNickMa 8.1 (440)
Tic-TacToeptrs 8.1 (441)
Eventhandling macro for classesToolsDevler 8.1 (441)
Integer Partitions from 1 to NChristopher Brown 8.1 (441)
Menu driven program in c programmingcampus 8.1 (444)
Output console text with type-writer effect.Michael Brandon Miller 8.1 (441)
Quick-sort using vector and iterator in STLJianbao Tao 8.1 (440)
Palindrome FunctionJason Weeks 8.1 (440)
String FunctionsDominic Vonk 8.1 (440)
Implementing a directory listing on LinuxJoshith C*nix4.1 (46)
GotoXYStack Overflow C*nix5.9 (420)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI4.9 (100)
Failproof xor (en/de)cryptionyzb3 CANSI5.7 (127)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI5.6 (127)
Simple linked list implementationyzb3 CANSI5.5 (137)
Word wrap functionSean Hubbard CANSI5.9 (137)
An example of Exception HandlingAli Nawkhas Murad C++ANSI4.6 (92)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI5.3 (112)
Function pointer to member function of classselvam C++ANSI4.0 (39)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI5.0 (103)
xor (en/de)cryption using a key fileyzb3 CANSI5.5 (116)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI4.5 (52)
string to bitstring, bitstring to stringEsa Karjalainen CANSI4.8 (53)
Calandar generator printing a full calendar for any yearJoe C++ANSI7.1 (208)
Templated queue classAli Nawkhas Murad C++ANSI5.6 (122)
Example of polymorphismAli Nawkhas Murad C++ANSI5.6 (202)
View the format of IEEE 754 floating point numbersAli Nawkhas Murad C++ANSI7.2 (417)
Simple swapping heapsortyzb3 C or C++ANSI5.9 (136)
Pascal's TriangleAli Nawkhas Murad C++ANSI6.8 (474)
Next 30

Add a snippet!