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)
GotoXYStack Overflow C*nix6.3 (338)
This C code uses the merge sort algorithm to sortAbhishek H.Dwivedi C or C++ANSI6.3 (569)
Three ways to do a swapDavid Nielsen C or C++ANSI6.3 (319)
Another merge sort of integer listManoj CANSI6.3 (11)
Merge sort of an integer listBibhubrata Narendra C or C++ANSI6.3 (12)
Implementing a directory listing on LinuxJoshith C*nix6.3 (12)
Dynamically Allocating a Multidimensional ArrayJared Hendrickson CANSI6.2 (10)
Rectangle Collision DetectionDavid Nielsen C or C++ANSI6.1 (171)
A code template for OpenGL / GLUTPerspective C or C++ANSI6.1 (226)
Template Calculatorprog-bman C++ANSI6.1 (276)
Print variables with file and line number for debuggingmike lear C++ANSI6.1 (12)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI6.1 (202)
how to implement strlwr in CSyed Rafey Husain C or C++ANSI5.9 (14)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.9 (137)
Macro to swap nibble of BYTET Sailesh C or C++ANSI5.9 (9)
euler approximation methoderic mbakop C or C++ANSI5.9 (256)
GetLastError error lookup toolKen Fitlike CWindows5.8 (185)
Calculates 1 variable statisticsPaul Kennedy C++ANSI5.8 (9)
similar to gotoxy; minimal screen control for wyseMike Kinney C or C++ANSI5.8 (156)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.8 (196)
This C code recursively sorts an array of upto 20Abhishek H.Dwivedi C or C++ANSI5.8 (209)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.7 (133)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.6 (238)
A portable card deck class with shufflingSlyMaelstrom C++ANSI5.6 (9)
Distanceprog-bman C++ANSI5.5 (184)
Simple integer binary search example source codeSyed Rafey Husain C or C++ANSI5.3 (6)
Integer subset generatortreenef C++ANSI5.3 (10)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.3 (11)
Without semicolon print the statement.Jeevanrao 5.3 (8)
Without semicolon print the statement.Jeevanrao 5.3 (8)
Next 30
Previous 30

Add a snippet!