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)
simple StopWatch with roundtrip timeNickMa 7.4 (565)
Menu driven program in c programmingcampus 7.4 (766)
Create a new file under linuxChol Nhial 7.4 (587)
Palindrome FunctionJason Weeks 7.4 (564)
Quick-sort using vector and iterator in STLJianbao Tao 7.3 (555)
Output console text with type-writer effect.Michael Brandon Miller 7.3 (545)
Integer Partitions from 1 to NChristopher Brown 7.4 (553)
Tic-TacToeptrs 7.3 (592)
Eventhandling macro for classesToolsDevler 7.4 (555)
String FunctionsDominic Vonk 7.4 (586)
Implementing a directory listing on LinuxJoshith C*nix5.1 (89)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI5.3 (138)
a simple clockrichmond caesar CANSI6.4 (1092)
GetLastError error lookup toolKen Fitlike CWindows5.4 (245)
useful macros, functions and tricksyzb3 CANSI5.5 (153)
Find the Prime Factors of Given NumberSHINE AIYYAPPAN CANSI4.8 (88)
Dynamically Allocating a Multidimensional ArrayJared Hendrickson CANSI4.5 (77)
Convert an integer into binary representationElabed Soufiane CANSI5.0 (91)
Creating, printing and free linked listsSyed Rafey Husain CANSI4.8 (78)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI5.5 (103)
Another merge sort of integer listManoj CANSI5.6 (90)
A singly linked list with a sentinel implementationyzb3 CANSI5.6 (63)
GotoXYStack Overflow C*nix5.7 (496)
Pascals Triangle Using Combination Function of IndicesSHINE AIYYAPPAN CANSI6.3 (581)
Useful string functionsyzb3 CANSI6.0 (217)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.3 (50)
Shorter version of gotoxyNedeljko CLinux5.5 (102)
xor (en/de)cryption using a key fileyzb3 CANSI5.4 (151)
Simple linked list implementationyzb3 CANSI5.6 (178)
Word wrap functionSean Hubbard CANSI5.6 (234)
Next 30