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)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.6 (237)
Count number of bits in a numberNaren Bala C or C++ANSI5.1 (9)
Creating, printing and free linked listsSyed Rafey Husain CANSI5.3 (6)
Distanceprog-bman C++ANSI5.5 (184)
Dynamically Allocating a Multidimensional ArrayJared Hendrickson CANSI5.8 (9)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI9.0 (19)
euler approximation methoderic mbakop C or C++ANSI5.9 (255)
Example of polymorphismAli Murad C++ANSI8.8 (38)
Examples of dynamic multidimensional arraysAli Murad C++ANSI8.7 (38)
Failproof xor (en/de)cryptionyzb3 CANSI8.9 (37)
Find size and storage capacity of primitive data typesAli Murad C++ANSI8.4 (32)
Find the minimum distance between two linesGiacomo C or C++ANSI5.3 (6)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple7.2 (13)
Find the Prime Factors of Given NumberSHINE AIYYAPPAN CANSI7.3 (10)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI7.5 (11)
friend function exampleAli Murad C++ANSI6.2 (25)
Function pointer to member function of classselvam C++ANSI7.6 (5)
Generate a spiral matrix for n elementsRaza C or C++ANSI5.9 (15)
GetLastError error lookup toolKen Fitlike CWindows5.8 (182)
GotoXYStack Overflow C*nix6.2 (321)
how to implement strlwr in CSyed Rafey Husain C or C++ANSI5.4 (10)
Implementing a directory listing on LinuxJoshith C*nix5.7 (9)
Initial values for static multidimensional arrayAli Murad C or C++ANSI8.5 (33)
Integer subset generatortreenef C++ANSI5.3 (10)
Knuth-Morris-Pratt (KMP) String Search AlgorithmSyed Rafey Husain C or C++ANSI7.1 (16)
Macro to swap nibble of BYTET Sailesh C or C++ANSI6.0 (7)
Merge sort of an integer listBibhubrata Narendra C or C++ANSI5.1 (9)
One line swap of integersabhilash C or C++ANSI8.1 (67)
Pascal's TriangleAli Murad C++ANSI8.5 (48)
Pascals Triangle Using Combination Function of IndicesSHINE AIYYAPPAN CANSI8.9 (30)
Next 30
Previous 30

Add a snippet!