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)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows8.9 (45)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.6 (238)
Count number of bits in a numberNaren Bala C or C++ANSI5.1 (9)
Create a new file under linuxChol Nhial 5.7 (6)
Creating, printing and free linked listsSyed Rafey Husain CANSI6.4 (8)
Distanceprog-bman C++ANSI5.5 (184)
Dynamically Allocating a Multidimensional ArrayJared Hendrickson CANSI6.2 (10)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI8.8 (45)
euler approximation methoderic mbakop C or C++ANSI5.9 (256)
Eventhandling macro for classesToolsDevler 5.7 (6)
Example of polymorphismAli Nawkhas Murad C++ANSI8.8 (81)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI8.7 (63)
Failproof xor (en/de)cryptionyzb3 CANSI8.9 (62)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI8.6 (53)
Find the minimum distance between two linesGiacomo C or C++ANSI7.2 (11)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple7.6 (15)
Find the Prime Factors of Given NumberSHINE AIYYAPPAN CANSI7.4 (17)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI8.2 (28)
friend function exampleAli Nawkhas Murad C++ANSI6.8 (33)
Function pointer to member function of classselvam C++ANSI8.6 (11)
Generate a spiral matrix for n elementsRaza C or C++ANSI6.6 (24)
GetLastError error lookup toolKen Fitlike CWindows5.8 (185)
GotoXYStack Overflow C*nix6.3 (338)
how to implement strlwr in CSyed Rafey Husain C or C++ANSI5.9 (14)
Implementing a directory listing on LinuxJoshith C*nix6.3 (12)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI8.4 (52)
Integer Partitions from 1 to NChristopher Brown 5.7 (6)
Integer subset generatortreenef C++ANSI5.3 (10)
Knuth-Morris-Pratt (KMP) String Search AlgorithmSyed Rafey Husain C or C++ANSI7.6 (385)
Macro to swap nibble of BYTET Sailesh C or C++ANSI5.9 (9)
Next 30
Previous 30

Add a snippet!