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 minimum distance between two linesGiacomo C or C++ANSI2.9 (36)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI4.4 (53)
Simple swapping heapsortyzb3 C or C++ANSI5.1 (162)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI4.8 (101)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows4.9 (97)
Color header for Windows that integrates with coutSang-drax C++Windows5.4 (257)
Distanceprog-bman C++ANSI5.4 (189)
Template Calculatorprog-bman C++ANSI5.5 (344)
A function to encrypt/decrypt a string using XOR eMajor_Small C++ANSI5.5 (455)
Permutation GeneratorTreenef C++ANSI5.6 (487)
View the contents of a directoryfinnepower C++Windows5.5 (209)
Calculates 1 variable statisticsPaul Kennedy C++ANSI2.5 (35)
A portable card deck class with shufflingSlyMaelstrom C++ANSI6.8 (399)
Integer subset generatortreenef C++ANSI4.9 (11)
An example use of a function pointerJayesh C++ANSI3.6 (43)
Calandar generator (based on snippet by Joe) printing a calendar for any yearTyler Veness C++ANSI6.6 (454)
Simple Windows Socket Server ExampleJahan Addison C++Windows5.3 (142)
Print variables with file and line number for debuggingmike lear C++ANSI2.6 (37)
Calandar generator printing a full calendar for any yearJoe C++ANSI6.2 (292)
Templated queue classAli Nawkhas Murad C++ANSI5.7 (129)
Example of polymorphismAli Nawkhas Murad C++ANSI5.6 (210)
View the format of IEEE 754 floating point numbersAli Nawkhas Murad C++ANSI6.5 (469)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI4.9 (104)
Function pointer to member function of classselvam C++ANSI4 (40)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI5.2 (113)
Examples of dynamic multidimensional arraysAli Nawkhas Murad C++ANSI5.8 (135)
An example of Exception HandlingAli Nawkhas Murad C++ANSI4.6 (94)
Pascal's TriangleAli Nawkhas Murad C++ANSI6.3 (532)
Templated stack class Ali Nawkhas Murad C++ANSI9.6 (4671)
Three Dimension Coordinate Systems ConverterAli Nawkhas Murad C++ANSI5.3 (111)
Next 30
Previous 30

Add a snippet!