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 7.4 (494)
simple StopWatch with roundtrip timeNickMa 7.4 (493)
Tic-TacToeptrs 7.4 (493)
Eventhandling macro for classesToolsDevler 7.4 (492)
Integer Partitions from 1 to NChristopher Brown 7.4 (495)
Menu driven program in c programmingcampus 7.4 (512)
Output console text with type-writer effect.Michael Brandon Miller 7.4 (492)
Quick-sort using vector and iterator in STLJianbao Tao 7.4 (491)
Palindrome FunctionJason Weeks 7.4 (492)
String FunctionsDominic Vonk 7.4 (491)
Implementing a directory listing on LinuxJoshith C*nix4.1 (46)
GotoXYStack Overflow C*nix5.7 (442)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI4.9 (100)
Failproof xor (en/de)cryptionyzb3 CANSI5.0 (151)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI5.7 (130)
Simple linked list implementationyzb3 CANSI5.5 (137)
Word wrap functionSean Hubbard CANSI5.2 (161)
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++ANSI6.1 (271)
Templated queue classAli Nawkhas Murad C++ANSI5.7 (126)
Example of polymorphismAli Nawkhas Murad C++ANSI5.6 (208)
View the format of IEEE 754 floating point numbersAli Nawkhas Murad C++ANSI6.5 (464)
Simple swapping heapsortyzb3 C or C++ANSI5.2 (160)
Pascal's TriangleAli Nawkhas Murad C++ANSI6.3 (527)
Next 30

Add a snippet!