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)
One line swap of integersabhilash C or C++ANSI5.9 (161)
Simple integer binary search example source codeSyed Rafey Husain C or C++ANSI5.3 (6)
A portable card deck class with shufflingSlyMaelstrom C++ANSI5.6 (9)
An example use of a function pointerJayesh C++ANSI3.3 (40)
Macro to swap nibble of BYTET Sailesh C or C++ANSI5.4 (10)
Integer subset generatortreenef C++ANSI5.3 (10)
Shorter version of gotoxyNedeljko CLinux5.1 (59)
Find the number of CPU Cores, for Windows, Mac or LinuxDirk-Jan Kroon C or C++Multiple4.1 (43)
This is Trigonometry Table made AlhamdulillahAbdul Haseeb Mir CWindows2.5 (31)
Color header for Windows that integrates with coutSang-drax C++Windows5.8 (231)
Convert NTSTATUS code to Win32 errorIan Abbott C or C++Windows4.9 (95)
Simple Windows Socket Server ExampleJahan Addison C++Windows5.8 (95)
View the contents of a directoryfinnepower C++Windows6.1 (184)
GetLastError error lookup toolKen Fitlike CWindows5.8 (185)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (197)
This C code assigns codes to a maximum of 10 charsAbhishek H.Dwivedi C or C++Windows2.9 (33)
Previous 30

Add a snippet!