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.7 (251)
Count number of bits in a numberNaren Bala C or C++ANSI4.7 (10)
Create a new file under linuxChol Nhial 7.4 (500)
Creating, printing and free linked listsSyed Rafey Husain CANSI2.9 (36)
Distanceprog-bman C++ANSI5.4 (189)
Dynamically Allocating a Multidimensional ArrayJared Hendrickson CANSI2.4 (36)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI4.9 (98)
euler approximation methoderic mbakop C or C++ANSI5.4 (281)
Eventhandling macro for classesToolsDevler 7.4 (497)
Example of polymorphismAli Nawkhas Murad C++ANSI5.6 (210)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI5.8 (135)
Failproof xor (en/de)cryptionyzb3 CANSI5.0 (152)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI5.2 (113)
Find the minimum distance between two linesGiacomo C or C++ANSI2.9 (36)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple5.1 (62)
Find the Prime Factors of Given NumberSHINE AIYYAPPAN CANSI4.0 (52)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI5.1 (60)
friend function exampleAli Nawkhas Murad C++ANSI6.5 (439)
Function pointer to member function of classselvam C++ANSI4 (40)
Generate a spiral matrix for n elementsRaza C or C++ANSI5.4 (83)
GetLastError error lookup toolKen Fitlike CWindows5.2 (210)
GotoXYStack Overflow C*nix5.6 (443)
how to implement strlwr in CSyed Rafey Husain C or C++ANSI3.4 (44)
Implementing a directory listing on LinuxJoshith C*nix4.1 (47)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI4.8 (101)
Integer Partitions from 1 to NChristopher Brown 7.4 (501)
Integer subset generatortreenef C++ANSI4.9 (11)
Knuth-Morris-Pratt (KMP) String Search AlgorithmSyed Rafey Husain C or C++ANSI6.6 (871)
Macro to swap nibble of BYTET Sailesh C or C++ANSI3.9 (47)
Menu driven program in c programmingcampus 7.5 (523)
Next 30
Previous 30

Add a snippet!