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)
Three ways to do a swapDavid Nielsen C or C++ANSI5.6 (374)
Tic-TacToeptrs 7.4 (502)
useful macros, functions and tricksyzb3 CANSI5.5 (116)
Useful string functionsyzb3 CANSI5.8 (157)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.2 (13)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.3 (168)
View the contents of a directoryfinnepower C++Windows5.5 (209)
View the format of IEEE 754 floating point numbersAli Nawkhas Murad C++ANSI6.5 (470)
Word wrap functionSean Hubbard CANSI5.3 (163)
xor (en/de)cryption using a key fileyzb3 CANSI5.5 (117)
Previous 30

Add a snippet!