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)
Singly linked list - insert, remove, add, countGirish Amara CANSI6.6 (755)
Output console text with type-writer effect.Michael Brandon Miller 6.4 (14)
Short program to print Hello World! without semicolonAli Nawkhas Murad 6.4 (14)
code to shut a computer with windows XPbenn mutisya 6.4 (14)
Menu driven program in c programmingcampus 6.4 (14)
Eventhandling macro for classesToolsDevler 6.4 (14)
this one is better because a potential overflow (of the + operation) is avoided 6.4 (14)
Create a new file under linuxChol Nhial 6.4 (14)
Without semicolon print the statement.Jeevanrao 6.4 (14)
Without semicolon print the statement.Jeevanrao 6.4 (14)
Tic-TacToeptrs 6.4 (14)
Integer Partitions from 1 to NChristopher Brown 6.4 (14)
String FunctionsDominic Vonk 6.2 (13)
simple StopWatch with roundtrip timeNickMa 6.2 (13)
String FunctionsDominic Vonk 6.2 (13)
Quick-sort using vector and iterator in STLJianbao Tao 6.2 (13)
Palindrome FunctionJason Weeks 6.2 (13)
Knuth-Morris-Pratt (KMP) String Search AlgorithmSyed Rafey Husain C or C++ANSI6.1 (514)
Permutation GeneratorTreenef C++ANSI5.7 (456)
GotoXYStack Overflow C*nix5.7 (389)
View the format of IEEE 754 floating point numbersAli Nawkhas Murad C++ANSI5.7 (116)
A function to reverse an integer arrayMajor_Small C or C++ANSI5.7 (434)
Simple swapping heapsortyzb3 C or C++ANSI5.7 (124)
Checking for powers of twoWebmaster C or C++ANSI5.7 (319)
A code template for OpenGL / GLUTPerspective C or C++ANSI5.7 (255)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.6 (238)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (369)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI5.6 (144)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI5.6 (74)
A portable card deck class with shufflingSlyMaelstrom C++ANSI5.6 (9)
Next 30

Add a snippet!