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)
similar to gotoxy; minimal screen control for wyseMike Kinney C or C++ANSI5.1 (181)
Print variables with file and line number for debuggingmike lear C++ANSI2.6 (37)
Count number of bits in a numberNaren Bala C or C++ANSI4.7 (10)
Shorter version of gotoxyNedeljko CLinux5.1 (60)
simple StopWatch with roundtrip timeNickMa 7.4 (495)
A game setup for DirectXPaul D C or C++ANSI5.4 (287)
Calculates 1 variable statisticsPaul Kennedy C++ANSI2.3 (34)
A code template for OpenGL / GLUTPerspective C or C++ANSI6.4 (636)
Distanceprog-bman C++ANSI5.4 (189)
Template Calculatorprog-bman C++ANSI5.4 (340)
Menu driven program in c programmingcampus 7.4 (518)
Tic-TacToeptrs 7.4 (495)
Generate a spiral matrix for n elementsRaza C or C++ANSI5.4 (83)
a simple clockrichmond caesar CANSI5.9 (745)
Color header for Windows that integrates with coutSang-drax C++Windows5.4 (257)
Word wrap functionSean Hubbard CANSI5.2 (162)
Function pointer to member function of classselvam C++ANSI4 (40)
Find the Prime Factors of Given NumberSHINE AIYYAPPAN CANSI4.0 (52)
Find The Sum of Digits of a Given NumberSHINE AIYYAPPAN CANSI5.1 (60)
Pascals Triangle Using Combination Function of IndicesSHINE AIYYAPPAN CANSI6.3 (511)
A portable card deck class with shufflingSlyMaelstrom C++ANSI6.8 (395)
GotoXYStack Overflow C*nix5.6 (443)
Knuth-Morris-Pratt (KMP) String Search AlgorithmSyed Rafey Husain C or C++ANSI6.6 (868)
Creating, printing and free linked listsSyed Rafey Husain CANSI2.9 (36)
binary tree creation, traversal and searchSyed Rafey Husain C or C++ANSI5.7 (173)
Simple integer binary search example source codeSyed Rafey Husain C or C++ANSI2.3 (33)
how to implement strlwr in CSyed Rafey Husain C or C++ANSI3.4 (44)
Macro to swap nibble of BYTET Sailesh C or C++ANSI3.9 (47)
Eventhandling macro for classesToolsDevler 7.4 (494)
Permutation GeneratorTreenef C++ANSI5.6 (487)
Next 30
Previous 30

Add a snippet!