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)
Palindrome FunctionJason Weeks 8.1 (430)
Integer Partitions from 1 to NChristopher Brown 8.1 (431)
this one is better because a potential overflow (of the + operation) is avoided 8.1 (431)
Eventhandling macro for classesToolsDevler 8.1 (431)
code to shut a computer with windows XPbenn mutisya 8.1 (431)
Short program to print Hello World! without semicolonAli Nawkhas Murad 8.1 (431)
Tic-TacToeptrs 8.1 (431)
Create a new file under linuxChol Nhial 8.1 (431)
simple StopWatch with roundtrip timeNickMa 8.1 (430)
Without semicolon print the statement.Jeevanrao 8.1 (431)
String FunctionsDominic Vonk 8.1 (430)
Without semicolon print the statement.Jeevanrao 8.1 (431)
Menu driven program in c programmingcampus 8.1 (431)
Output console text with type-writer effect.Michael Brandon Miller 8.1 (431)
Quick-sort using vector and iterator in STLJianbao Tao 8.1 (430)
String FunctionsDominic Vonk 8.1 (430)
Simple linked list implementationyzb3 CANSI5.2 (128)
Word wrap functionSean Hubbard CANSI5.6 (124)
useful macros, functions and tricksyzb3 CANSI5.2 (104)
Singly linked list - insert, remove, add, countGirish Amara CANSI7.3 (1649)
Failproof xor (en/de)cryptionyzb3 CANSI5.5 (118)
xor (en/de)cryption using a key fileyzb3 CANSI5.2 (107)
Another merge sort of integer listManoj CANSI3.5 (40)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.6 (12)
Convert an integer into binary representationElabed Soufiane CANSI3.4 (43)
string to bitstring, bitstring to stringEsa Karjalainen CANSI4.6 (50)
Implementing a directory listing on LinuxJoshith C*nix2.9 (37)
Creating, printing and free linked listsSyed Rafey Husain CANSI2.9 (35)
Dynamically Allocating a Multidimensional ArrayJared Hendrickson CANSI2.5 (35)
GotoXYStack Overflow C*nix5.8 (408)
Next 30

Add a snippet!