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 (497)
simple StopWatch with roundtrip timeNickMa 7.4 (495)
Tic-TacToeptrs 7.4 (495)
Eventhandling macro for classesToolsDevler 7.4 (494)
Integer Partitions from 1 to NChristopher Brown 7.4 (498)
Menu driven program in c programmingcampus 7.4 (518)
Output console text with type-writer effect.Michael Brandon Miller 7.4 (495)
Quick-sort using vector and iterator in STLJianbao Tao 7.4 (493)
Palindrome FunctionJason Weeks 7.4 (496)
String FunctionsDominic Vonk 7.4 (493)
Implementing a directory listing on LinuxJoshith C*nix4.1 (47)
GotoXYStack Overflow C*nix5.6 (443)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI4.8 (101)
Failproof xor (en/de)cryptionyzb3 CANSI5.0 (152)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI5.7 (132)
Simple linked list implementationyzb3 CANSI5.4 (138)
Word wrap functionSean Hubbard CANSI5.2 (162)
An example of Exception HandlingAli Nawkhas Murad C++ANSI4.6 (94)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI5.2 (113)
Function pointer to member function of classselvam C++ANSI4 (40)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI4.9 (104)
xor (en/de)cryption using a key fileyzb3 CANSI5.5 (117)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI4.4 (53)
string to bitstring, bitstring to stringEsa Karjalainen CANSI4.8 (54)
Calandar generator printing a full calendar for any yearJoe C++ANSI6.0 (275)
Templated queue classAli Nawkhas Murad C++ANSI5.7 (128)
Example of polymorphismAli Nawkhas Murad C++ANSI5.6 (210)
View the format of IEEE 754 floating point numbersAli Nawkhas Murad C++ANSI6.5 (466)
Simple swapping heapsortyzb3 C or C++ANSI5.1 (161)
Pascal's TriangleAli Nawkhas Murad C++ANSI6.3 (529)
Next 30

Add a snippet!