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)
this one is better because a potential overflow (of the + operation) is avoided 5.7 (6)
Output console text with type-writer effect.Michael Brandon Miller 5.7 (6)
Integer Partitions from 1 to NChristopher Brown 5.7 (6)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.6 (238)
A portable card deck class with shufflingSlyMaelstrom C++ANSI5.6 (9)
Distanceprog-bman C++ANSI5.5 (184)
Simple integer binary search example source codeSyed Rafey Husain C or C++ANSI5.3 (6)
Integer subset generatortreenef C++ANSI5.3 (10)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.3 (11)
Count number of bits in a numberNaren Bala C or C++ANSI5.1 (9)
simple StopWatch with roundtrip timeNickMa 5.0 (5)
Quick-sort using vector and iterator in STLJianbao Tao 5.0 (5)
Palindrome FunctionJason Weeks 5.0 (5)
String FunctionsDominic Vonk 5.0 (5)
String FunctionsDominic Vonk 5.0 (5)
A singly linked list with a sentinel implementationyzb3 CANSI4.7 (20)
Previous 30

Add a snippet!