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)
A simple example of hashtableAli Nawkhas Murad C++ANSI7.9 (72)
Shorter version of gotoxyNedeljko CLinux7.9 (34)
Useful string functionsyzb3 CANSI7.9 (81)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI7.8 (47)
A simple double linked list using OOP techniquesAli Nawkhas Murad C++ANSI7.8 (85)
Simple linked list implementationyzb3 CANSI7.7 (60)
Knuth-Morris-Pratt (KMP) String Search AlgorithmSyed Rafey Husain C or C++ANSI7.6 (385)
Singly linked list - insert, remove, add, countGirish Amara CANSI7.6 (479)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple7.6 (15)
This is Trigonometry Table made AlhamdulillahAbdul Haseeb Mir CWindows7.6 (7)
Simple Windows Socket Server ExampleJahan Addison C++Windows7.4 (55)
string to bitstring, bitstring to stringEsa Karjalainen CANSI7.4 (18)
Permutation GeneratorTreenef C++ANSI7.4 (333)
Find the Prime Factors of Given NumberSHINE AIYYAPPAN CANSI7.4 (17)
An example use of a function pointerJayesh C++ANSI7.3 (14)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI7.2 (25)
Find the minimum distance between two linesGiacomo C or C++ANSI7.2 (11)
Calandar generator printing a full calendar for any yearJoe C++ANSI7.2 (33)
View the contents of a directoryfinnepower C++Windows6.9 (160)
friend function exampleAli Nawkhas Murad C++ANSI6.8 (33)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI6.6 (345)
Convert an integer into binary representationElabed Soufiane CANSI6.6 (16)
Generate a spiral matrix for n elementsRaza C or C++ANSI6.6 (24)
A function to reverse an integer arrayMajor_Small C or C++ANSI6.6 (358)
a simple clockrichmond caesar CANSI6.5 (428)
Checking for powers of twoWebmaster C or C++ANSI6.4 (267)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI6.4 (29)
Creating, printing and free linked listsSyed Rafey Husain CANSI6.4 (8)
Color header for Windows that integrates with coutSang-drax C++Windows6.4 (207)
A game setup for DirectXPaul D C or C++ANSI6.3 (231)
Next 30
Previous 30

Add a snippet!