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)
Calandar generator printing a full calendar for any yearJoe C++ANSI5.2 (70)
similar to gotoxy; minimal screen control for wyseMike Kinney C or C++ANSI5.1 (180)
Shorter version of gotoxyNedeljko CLinux5.1 (59)
Conversions between number systemsAli Nawkhas Murad C++ANSI5.1 (106)
Count number of bits in a numberNaren Bala C or C++ANSI5.1 (9)
Templated stack class Ali Nawkhas Murad C++ANSI5.1 (101)
Pascal's TriangleAli Nawkhas Murad C++ANSI5.1 (163)
The standard ASCII table generator.Ali Nawkhas Murad C++ANSI5.0 (100)
An example of simple stack using linked lists.Ali Nawkhas Murad C++ANSI5.0 (114)
Find size and storage capacity of primitive data typesAli Nawkhas Murad C++ANSI5.0 (103)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.0 (157)
xor (en/de)cryption using a key fileyzb3 CANSI4.9 (98)
binary addition using stack in STLanmol C++ANSI4.9 (96)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows4.9 (95)
A singly linked list with a sentinel implementationyzb3 CANSI4.9 (21)
Simple linked list implementationyzb3 CANSI4.9 (117)
An example of using the same variable name in different scopesAli Nawkhas Murad C++ANSI4.9 (101)
Initial values for static multidimensional arrayAli Nawkhas Murad C or C++ANSI4.9 (100)
Simple Windows Socket Server ExampleJahan Addison C++Windows4.8 (119)
dynamically create and initialise 4d arrayG.Watt.Porteous CANSI4.8 (96)
useful macros, functions and tricksyzb3 CANSI4.8 (95)
ASCII table generatorAbdul Haseeb Mir C++ANSI4.8 (105)
Pascals Triangle Using Combination Function of IndicesSHINE AIYYAPPAN CANSI4.7 (145)
friend function exampleAli Nawkhas Murad C++ANSI4.7 (66)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI4.7 (68)
Simple example for using thousand separator (,)Ali Nawkhas Murad C++ANSI4.5 (87)
An example of Exception HandlingAli Nawkhas Murad C++ANSI4.5 (90)
Another way to swap 2 numbersMaganti Venkatesh C or C++ANSI4.3 (50)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple4.1 (43)
Generate a spiral matrix for n elementsRaza C or C++ANSI4.1 (50)
Next 30
Previous 30

Add a snippet!