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)
An example use of a function pointerJayesh C++ANSI6.1 (9)
Template Calculatorprog-bman C++ANSI6.1 (273)
a short BubbleSort algoritm for Integer ArraysMajor_Small C or C++ANSI6.0 (199)
Macro to swap nibble of BYTET Sailesh C or C++ANSI6.0 (7)
string to bitstring, bitstring to stringEsa Karjalainen CANSI6.0 (10)
Another merge sort of integer listManoj CANSI5.9 (10)
Generate a spiral matrix for n elementsRaza C or C++ANSI5.9 (15)
euler approximation methoderic mbakop C or C++ANSI5.9 (255)
A code template for OpenGL / GLUTPerspective C or C++ANSI5.8 (208)
Dynamically Allocating a Multidimensional ArrayJared Hendrickson CANSI5.8 (9)
similar to gotoxy; minimal screen control for wyseMike Kinney C or C++ANSI5.8 (156)
Validate Longitudinal Redundancy Checksum (LRC)Darko Kolaković C or C++ANSI5.8 (133)
GetLastError error lookup toolKen Fitlike CWindows5.8 (182)
using struct tm, time_t, and time to create a simple clockDieter Manstein CANSI5.7 (8)
This C code recursively sorts an array of upto 20Abhishek H.Dwivedi C or C++ANSI5.7 (207)
Implementing a directory listing on LinuxJoshith C*nix5.7 (9)
A very simple frames per second functionJeff Verkoeyen C or C++Windows5.7 (189)
Calculates the closest point to a segmentAdrián Deccico C or C++ANSI5.7 (132)
Converts a real number to the string.Darko Kolakoviћ C or C++ANSI5.6 (237)
Distanceprog-bman C++ANSI5.5 (184)
how to implement strlwr in CSyed Rafey Husain C or C++ANSI5.4 (10)
Find the minimum distance between two linesGiacomo C or C++ANSI5.3 (6)
Creating, printing and free linked listsSyed Rafey Husain CANSI5.3 (6)
Simple integer binary search example source codeSyed Rafey Husain C or C++ANSI5.3 (6)
Integer subset generatortreenef C++ANSI5.3 (10)
Calculates 1 variable statisticsPaul Kennedy C++ANSI5.3 (8)
Merge sort of an integer listBibhubrata Narendra C or C++ANSI5.1 (9)
Count number of bits in a numberNaren Bala C or C++ANSI5.1 (9)
A portable card deck class with shufflingSlyMaelstrom C++ANSI5.0 (8)
A singly linked list with a sentinel implementationyzb3 CANSI3.6 (16)
Next 30
Previous 30

Add a snippet!