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)
Find the Prime Factors of Given NumberSHINE AIYYAPPAN CANSI7.3 (10)
Failproof xor (en/de)cryptionyzb3 CANSI8.9 (37)
xor (en/de)cryption using a key fileyzb3 CANSI8.7 (26)
string to bitstring, bitstring to stringEsa Karjalainen CANSI6.0 (10)
Implementing a directory listing on LinuxJoshith C*nix5.7 (9)
Singly linked list - insert, remove, add, countGirish Amara CANSI7.5 (178)
a simple clockrichmond caesar CANSI6.4 (416)
Another merge sort of integer listManoj CANSI5.9 (10)
Dynamically Allocating a Multidimensional ArrayJared Hendrickson CANSI5.8 (9)
Convert an integer into binary representationElabed Soufiane CANSI6.2 (14)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.7 (8)
Creating, printing and free linked listsSyed Rafey Husain CANSI5.3 (6)
Simple linked list implementationyzb3 CANSI8.4 (28)
Word wrap functionSean Hubbard CANSI8.5 (33)
Pascals Triangle Using Combination Function of IndicesSHINE AIYYAPPAN CANSI8.9 (30)
GetLastError error lookup toolKen Fitlike CWindows5.8 (182)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI9.0 (19)
This is Trigonometry Table made AlhamdulillahAbdul Haseeb Mir CWindows6.6 (5)
Shorter version of gotoxyNedeljko CLinux7.8 (25)
A singly linked list with a sentinel implementationyzb3 CANSI3.6 (16)
Useful string functionsyzb3 CANSI8.4 (41)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI7.5 (11)
useful macros, functions and tricksyzb3 CANSI8.6 (26)
GotoXYStack Overflow C*nix6.2 (321)
Find the minimum distance between two linesGiacomo C or C++ANSI5.3 (6)
Macro to swap nibble of BYTET Sailesh C or C++ANSI6.0 (7)
One line swap of integersabhilash C or C++ANSI8.1 (67)
Generate a spiral matrix for n elementsRaza C or C++ANSI5.9 (15)
Initial values for static multidimensional arrayAli Murad C or C++ANSI8.5 (33)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI6.5 (13)
Next 30

Add a snippet!