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 Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI8.2 (33)
GetLastError error lookup toolKen Fitlike CWindows5.8 (185)
A singly linked list with a sentinel implementationyzb3 CANSI4.9 (21)
Find the Prime Factors of Given NumberSHINE AIYYAPPAN CANSI7.2 (20)
Pascals Triangle Using Combination Function of IndicesSHINE AIYYAPPAN CANSI8.3 (67)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI8.7 (48)
a simple clockrichmond caesar CANSI6.5 (431)
This is Trigonometry Table made AlhamdulillahAbdul Haseeb Mir CWindows7.6 (7)
Shorter version of gotoxyNedeljko CLinux7.9 (34)
Useful string functionsyzb3 CANSI7.9 (83)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows9.0 (46)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI7.2 (25)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI8.4 (52)
This C code recursively sorts an array of upto 20Abhishek H.Dwivedi C or C++ANSI5.8 (209)
Simple swapping heapsortyzb3 C or C++ANSI8.6 (75)
Find the minimum distance between two linesGiacomo C or C++ANSI7.2 (11)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (196)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI6.6 (36)
Knuth-Morris-Pratt (KMP) String Search AlgorithmSyed Rafey Husain C or C++ANSI7.6 (387)
A function to reverse an integer arrayMajor_Small C or C++ANSI6.6 (358)
Count number of bits in a numberNaren Bala C or C++ANSI5.1 (9)
Three ways to do a swapDavid Nielsen C or C++ANSI6.3 (319)
euler approximation methoderic mbakop C or C++ANSI5.9 (256)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.9 (138)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.6 (238)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI6.1 (171)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.7 (133)
similar to gotoxy; minimal screen control for wyseMike Kinney C or C++ANSI5.8 (156)
This C code assigns codes to a maximum of 10 charsAbhishek H.Dwivedi C or C++Windows8.1 (9)
This C code uses the merge sort algorithm to sortAbhishek H.Dwivedi C or C++ANSI6.3 (571)
Next 30
Previous 30

Add a snippet!