268 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for jnbgames.dev

The program below is written in **C** and is used to convert numbers to words. These operations are beneficial during the development of word processing applications. The program takes the **input** file that contains the number and **outputs** the results in an output file. Let me know if you find …

Member Avatar for Dani
0
403
Member Avatar for jnbgames.dev

The program below is written in C and creates a stack that holds the values of a maze. This structure is beneficial during the development of a desktop game that uses a maze. Let me know if you find the code below helpful and if you have any additional suggestions:

Member Avatar for Dani
1
280
Member Avatar for jnbgames.dev

The program below is written in C and is used to perform fast number operations. These operations are beneficial during the development of spreadsheet applications. Let me know if you find the code below helpful and if you have any additional suggestions:

Member Avatar for rproffitt
0
226
Member Avatar for harshchandra

This is a simple archery Game developed in C language . The aim of the game is to shoot the balloons and score as much points as you can . The game have three levels. Platform used is Turbo C++ IDE . Standard Graphics.h functions are used.

Member Avatar for 26_Anuja
0
4K
Member Avatar for thomasdoejr

Write a program using for loops to produce an R by C rectangle, where R and C are provided by the user. The following are the triangles for different values of R and C. R is the number of rows and C is the number of columns

Member Avatar for rproffitt
0
324
Member Avatar for majestic0110

Hi all, here is a small program I have worked on over these last two days, I have submitted it in the hopes of some constructive criticism and suggestions (please be kind, this is one of my earlier C projects lol). This is a small console application that simulates a …

Member Avatar for Baneeishaque
1
10K
Member Avatar for praneeth_gunda

This Program implements the Predictive Parsing Of the grammar E->E+T/T F->F*T/F F->id(Identifier)

Member Avatar for yesim
1
26K
Member Avatar for chandrabhanu

Above program takes input of coefficient and power separately of 2 different polynomials add them up to a new polynomial.It is successfully compiled and executed in DEV CPP as C file.It Turbo C compiler add void before main function to avoid warning messages.

Member Avatar for Nithesh_1
0
49K
Member Avatar for andrewll2

This snippet converts a CIDR notated IP address to a range of IP addresses in decimal, dotted notation. Eg.: 192.168.1.255/31 => 192.168.1.254 - 192.168.1.255

Member Avatar for JamesCherrill
0
4K
Member Avatar for Graphix

Hey everybody, Lately I have written the game Hangman in many different languages (C, JavaScript, Java and PHP so far). Here is the code snippet for C! It uses a words file, on the bottom of this post you will see a small example of a few words. You can …

Member Avatar for Anish_4
0
4K
Member Avatar for directorabbey

void Halt (); void Reply (const char * num,uint8_t stat); { this is the error message for this code 7|error: 'uint8_t' has not been declared 9|error: expected unqualified-id before '{' token

Member Avatar for directorabbey
0
266
Member Avatar for tyrantbrian

Following is a matrix multiplication code written in MPI (Message Passing Interface) which could be run on CPU cluster for parallel processing. This has been successfully tested with two square matrices, each of the size 1500*1500.

Member Avatar for Gustavo_4
2
18K
Member Avatar for Luckychap

A simple graphical year calendar. Compiler: Turbo C In main current year is set manually, for more generic way use date function to get current year.

Member Avatar for santlaha
0
345
Member Avatar for ayeswarya

[CODE]struct PCB* handleProcessArrival_PP(struct PCB *processhead,struct PCB *processtail,struct PCB *currProcess,struct PCB *newProcess,int currTime){ if(currProcess==NULL){ newProcess->executionStartTime = currTime; newProcess->executionEndTime = currTime+newProcess->totalBurstTime; newProcess->remainingBurstTime = newProcess->totalBurstTime; if(newProcess->processID==processhead->processID){ processhead= newProcess->next; printf("processhead in case 1 %d \n",processhead->processID); } currProcess=newProcess; printf("***current process = new process%d \n",currProcess->processID); contents(processhead); return currProcess; //return processhead; } if (currProcess->processID !=0){ contents(processhead); if(currProcess->processPriority>newProcess->processPriority){//new …

Member Avatar for rubberman
-1
3K
Member Avatar for Dave Sinkula

Many times [inlinecode]strtok[/inlinecode] is recommended for parsing a string; I don't care for [inlinecode]strtok[/inlinecode]. Why? [list][*]It modifies the incoming string, so it cannot be used with string literals or other constant strings. [*]The identity of the delimiting character is lost. [*]It uses a static buffer while parsing, so it's not …

Member Avatar for anti_neoliberal
0
10K
Member Avatar for dileepkumar235

Login functionality in C-language : Here the user enters the user id and password. The entered user id and password will be compared with the stored ones and user will be authenticated. While user enters password, characters should not be displayed on the screen. user id comparison must be case …

Member Avatar for Tanmay_1
0
4K
Member Avatar for vegaseat

The bubble sort is slow and I thought it would be interesting to visualize the progress as it sorts an array of integers.

Member Avatar for David_50
5
728
Member Avatar for jephthah

too many new and intermediate users of C attempt to use the command [icode]fflush(stdin)[/icode] to "flush the input buffer". this is patently wrong. the rule is (and click if you don't believe me) : [URL="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1052863818&id=1043284351"]NEVER [/URL][URL="http://answers.yahoo.com/question/index?qid=20071013052534AAuxWmW"]USE [/URL][URL="http://www.gidnetwork.com/b-57.html"]"FFLUSH()"[/URL] [URL="http://www.linuxforums.org/forum/linux-programming-scripting/41287-problem-fflush-stdin-function.html"]ON [/URL][URL="http://www.it.usyd.edu.au/~dasymond/mirror/c-faq/stdio/gets_flush2.html"]INPUT [/URL][URL="http://www.cplusplus.com/forum/general/6554/"]STREAMS [/URL][URL="http://c-faq.com/stdio/stdinflush.html"]SUCH [/URL][URL="http://gcc.gnu.org/ml/gcc-help/2009-01/msg00287.html"]AS [/URL][URL="http://www.dreamincode.net/forums/showtopic45833.htm"]"STDIN" [/URL] here is one method of properly …

Member Avatar for David_50
0
6K
Member Avatar for vegaseat

I have joined the thousands who have done it before, and have compared a number of sorting routines. The sorting is done on the same random-integer arrays. No surprises, quicksort wins this simple comparison hands down. There are clever combinations of sorting routines that are faster, like the snippet by …

Member Avatar for vegaseat
2
249
Member Avatar for anurag_pareek

it is a simple program but the beuty lies in its shortness it is written in least line as possible By :- Anurag Pareek

Member Avatar for Indra_1
0
229
Member Avatar for harshchandra
Member Avatar for athlon32

This is just a little example of howto make a Gtk+ application go fullscreen. This is really useful in game programming. Please rate/comment/report errors :icon_mrgreen:

Member Avatar for Stefan_4
0
3K
Member Avatar for L7Sqr

Often times it is useful to instrument a program you do not have the source to in an attempt to learn more about it. This can be for debugging purposes, blackbox testing, or for providing alternate versions of common functions/libraries (to name a few). On Linux, there is a very …

2
1K
Member Avatar for zegarnek

Hi, I am just playing with C code in the console under Linux. In the old times a fair bit of code was written for a console; programs were operating in text mode, creating menues was quite a fun. I coded very simple c routine to print a strings of …

Member Avatar for N1GHTS
1
3K
Member Avatar for lazylibran82
Member Avatar for bumsfeld

A simple program to show you how to create a table of Fahrenheit and Celsius values using a for loop. You may be able to learn from this code.

Member Avatar for rubberman
1
274
Member Avatar for Jaks_maths

This Program prints the numbers in given array(Row-Major Order) in Spiral order. Ex: Order Is 3*4 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Spiral Order Of Matrix is 11 12 13 14 18 22 26 25 24 23 19 15 16 …

Member Avatar for rubberman
0
290
Member Avatar for NEMO_1990_2007

The greatest common divisor of integers x and y is the largest integer that evenly divides both x and y. Write a recursive method Gcd that returns the greatest common divisor of x and y. The Gcd of x and y is defined recursively as follows: If y is equal …

Member Avatar for David W
0
511
Member Avatar for mvmalderen

One of the things which attracted my attention was that there are often newbies asking how to create a password program in C/C++, often they don't succeed, well here's my response, you can use it for any purpose you want, one thing you'll have to keep in mind is that …

Member Avatar for Remy1990
0
8K
Member Avatar for mayankjoin

The End.