C project on TypeWriter

Computer Science & Engineering Discipline,

Khulna University, Khulna.

Type Writer Project in C

Submitted by

Student ID                   Name

180226   –    Md. Shazzadul Ahsan

180229   –    Md. Ashadousjaman Rony

180232   –    Mehedi Hasan Shanto

180235   –    Md. Azizul Haque.



Introduction: Typing is the basic command to run a computer and your typing speed plays vital role while working in computer to save time. Here I have presented a Typing Tutor Project in C to measure user’s typing speed and to enhance their typing speed. This is a simple console application written in C programming language, and compiled using GNU GCC compiler on Code::Blocks IDE.

The source code of Typing Tutor Project in C consists of over 250+lines of code. The project source code effectively utilizes the user defined functions and the concept of file handling. You can directly download the application file and source code of this project from the link below.

How to play

  • Download the project files from google drive… or github…

    note: keep main.cpp, first.txt and typingHistory.txt in the same directory…

  • Firstly when you run the game you will see the start menu with multiple options. The outlook will be like this…

  • If you choose option ‘1’ to play game from the keyboard , you will get a window.. here

Enter your name here to save your data, you can start typing now as following text

Then you get your typing accuracy and typing speed in WPM with mistakes and get a window like this

Press ‘2’ to show the main menu from any where… here is the link…

  • We keep some instruction for you in option ‘3’ like this… link…

  • Press ‘4’ for history in this game. As you can compare with others…
    You can compare you accuracy and word. You will also see your typing time


Important function use in Project

The major user defined functions used in the source code of this project are:

strtok(): strtok() is one of the inbuilt string function in c programming which is used to split the given string with the given character. The following diagram clearly illustrate the working principle of strtok() :- link

strtok() split the string into parts, wherever the given character is present in the string. Splitting is done by replacing a user mentioned delimitting character with ‘\0’ i.e) Null character.

Syntax –strtok()

  • strtok() accepts two parameters,

  • First parameter must be a string and second parameter must be a character.

  • Second parameter must be a delimiting characters like , : ;

  • To use strtok() inbuilt string functions in C, we need to declare #include<string.h> header file.

  • Syntax

strtok(string, charecter);


The C library function char *gets(char *str) reads a line from stdin and stores it into the string pointed to by str. It stops when either the newline character is read or when the end-of-file is reached, whichever comes first.


char *gets(char *str)


  • str − This is the pointer to an array of chars where the C string is stored.

Return Value

This function returns str on success, and NULL on error or when end of file occurs, while no characters have been read.

fopen():The C library function FILE *fopen(const char *filename, const char *mode) opens the filename pointed to, by filename using the given mode.

Following is the declaration for fopen() function.

FILE *fopen(const char *filename, const char *mode);


  • Filename − This is the C string containing the name of the file to be opened.

  • Mode − This is the C string containing a file access mode. It includes −


Mode & Description



Opens a file for reading. The file must exist.



Creates an empty file for writing. If a file with the same name already exists, its content is erased and the file is considered as a new empty file.



Appends to a file. Writing operations, append data at the end of the file. The file is created if it does not exist.



Opens a file to update both reading and writing. The file must exist.



Creates an empty file for both reading and writing.



Opens a file for reading and appending.

Return Value

This function returns a FILE pointer. Otherwise, NULL is returned and the global variable errno is set to indicate the error.

fclose():The C library function int fclose(FILE *stream) closes the stream. All buffers are flushed.


Following is the declaration for fclose() function.

int fclose(FILE *stream);


  • Stream − This is the pointer to a FILE object that specifies the stream to be closed.

Return Value

This method returns zero if the stream is successfully closed. On failure, EOF is returned.


The C library function int fprintf(FILE *stream, const char *format, …)sends formatted output to a stream.


Following is the declaration for fprintf() function.

int fprintf(FILE *stream, const char *format, …);

fseek():The C library function int fseek(FILE *stream, long int offset, int whence) sets the file position of the stream to the given offset.


Following is the declaration for fseek() function.

int fseek(FILE *stream, long int offset, int whence);

fgets():The C library function char *fgets(char *str, int n, FILE *stream) reads a line from the specified stream and stores it into the string pointed to by str. It stops when either (n-1) characters are read, the newline character is read, or the end-of-file is reached, whichever comes first.


Following is the declaration for fgets() function.

char *fgets(char *str, int n, FILE *stream)


  • str − This is the pointer to an array of chars where the string read is stored.

  • n − This is the maximum number of characters to be read (including the final null-character). Usually, the length of the array passed as str is used.

  • stream − This is the pointer to a FILE object that identifies the stream where characters are read from.

Return Value

On success, the function returns the same str parameter. If the End-of-File is encountered and no characters have been read, the contents of str remain unchanged and a null pointer is returned.

If an error occurs, a null pointer is returned.


The C library function void rewind(FILE *stream) sets the file position to the beginning of the file of the given stream.


Following is the declaration for rewind() function.

void rewind(FILE *stream)


  • stream − This is the pointer to a FILE object that identifies the stream.

Returns: This function does not return any value.



The C library function long int ftell(FILE *stream) returns the current file position of the given stream.


Following is the declaration for ftell() function.

long int ftell(FILE *stream);


  • stream − This is the pointer to a FILE object that identifies the stream.

Return Value

This function returns the current value of the position indicator. If an error occurs, -1L is returned, and the global variable errno is set to a positive value.



The C library function void srand(unsigned int seed) seeds the random number generator used by the function rand.


Following is the declaration for srand() function.

void srand(unsigned int seed);


  • seed − This is an integer value to be used as seed by the pseudo-random number generator algorithm.

Return Value

This function does not return any value.

We use this function to take random input from file.


The C library function int system(const char *command) passes the command name or program name specified by command to the host environment to be executed by the command processor and returns after the command has been completed.


Following is the declaration for system() function.

int system(const char *command)


  • command − This is the C string containing the name of the requested variable.

This is very useful function to clear screen at run time of the program


The C library function int rand(void) returns a pseudo-random number in the range of 0 to RAND_MAX.

RAND_MAX is a constant whose default value may vary between implementations but it is granted to be at least 32767.


  • This project provides certain name as user by default and there a facility to create a new user too. You can enter your name as user.

  • In the project, you can view the total statistics.

  • The record option in the project is for displaying the data of user which has already used the application. you can view typing speed, accuracy.

  • If you want to terminate the program without any use, you can select exit option in the main menu.

Thank you

A Calendar Event Management Program Using C



ABSTRACT:  We have made a Calendar Event Management program using ‘C’ programming language. We approached in a structured way. As ‘C’ is a Structured Programming Language, so we used ‘C’ to write the program. To keep all tasks organized was our main goal. So, we made a calendar program so that one can add events on a particular date. It will help one to keep up to date with one’s work.


INDEX TERMS: Introduction, Preprocessor Directives, User Defined Functions ,Time Function, Graphical Function.


INTRODUCTION: Our calendar is in year view. To write the program we used ‘CODE BLOCKS’ as IDE. We made a ‘Today’s date’ feature, point today’s date feature, go to date feature, add task feature in the program. First, we made a program just to make a calendar. Then using graphics, we printed the calendar on the console. Then to beautify the program we made a load screen containing today’s date .


PREPROCESSOR DIRECTIVES: To access current date and time we need to use the ‘time.h’ preprocessor directive. As we also used graphical function we used ‘graphics.h’ and ‘windows.h’ preprocessor. To use graphics.h we need to download the header file and install the header in our IDE. One can get instruction on how to download and install here. To use ‘C’ standard library functions we used ‘stdio.h’ and ‘stdlib.h’ preprocessor directives.

Preprocessor Directives: 


TIME FUNCTION: As we added ‘Today’s date’ feature so it was must to use ‘time.h’ header. The time.h header defines four variable types, two macro and various functions for manipulating date and time. There are four types of variable types in ‘time.h’ preprocessor directive.


  1. size_t

This is the unsigned integral type and is the result of the sizeof keyword.

  1. clock_t

This is a type suitable for storing the processor time.

  1. time_t

This is a type suitable for storing the calendar time.

  1. struct tm

This is structure use to hold the time and date.


Here in our program used ‘time_t’ and ‘struct tm’ type variable.

The tm structure has the following definition –



struct tm    {

int tm sec;             /* seconds, range 0 to 59 */

int tm min;            /* minutes, range 0 to 59 */

int tm hour;          /* hours, range 0 to 23 */

int tm mday;         /* day of month, range 1 to 31 */

int tm mon;           /* month, range 0 to 11 */

int tm year;           /* the number of years since 1900 */

int tm wday;         /* day of the week, range 0 to 6 */

int tm yday;          /* day in the year, range 0 to 365 */

int tm isdst;          /* daylight saving time */



We also used the time() function in the program. The C library function time_t time(time_t *seconds) returns the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds. If seconds is not NULL, the return value is also stored in variable seconds.


We declared the time() function as “time(time_t current time)” in the progam.




In our program we used some graphics function to beautify our program. Graphic functions that we used are

  1. initgraph();
  2. bar();
  3. setcolor();
  4. setfillstyle();
  5. floodfill();
  6. moveto();
  7. settextstyle();
  8. outtextxy();
  9. cleardevice();
  10. closegraph();



  1. initgraph();

          To use the graphical console we need to initialize the graphical drive which is already in our computer. So we use the initgraph() function to initialize the graphic drive.

To use this function we need to type “initgraph(&gd,&gm,”path”)”.

This way we initialize the graphic drive.

  1. bar()

Bar function is used to draw a 2-dimensional, rectangular filled in bar. Coordinates of left top and right bottom corner are required to draw the bar. Left specifies the X-coordinate of top left corner, top specifies the Y-coordinate of top left corner, right specifies the X-coordinate of right bottom corner, bottom specifies the Y-coordinate of right bottom corner.  

Declaration: void bar(int left, int top, int right, int bottom);

  1. setcolor()

 In  graphics each color is assigned a number. Total 16 colors are available. Strictly speaking number of available colors depends on current graphics mode and driver. For Example: – BLACK is assigned 0, RED is assigned 4 etc. setcolor() function is used to change the current drawing color e.g. setcolor(RED) or setcolor(4) changes the current drawing color to RED. The  default drawing color is WHITE.

                    Declaration: void setcolor(int color);

  1. setfillstyle()

setfillstyle() function sets the current fill pattern and fill color.


Declaration: void setfillstyle( int pattern, int color);

  1. floodfill()

floodfill function is used to fill an enclosed area. Current fill pattern and fill color is used to fill the area. (x, y) is any point on the screen if (x,y) lies inside the area then inside will be filled otherwise outside will be filled, border specifies the color of boundary of area.


Declaration: void floodfill(int x, int y, int border);

  1. moveto()

move() function is used to move to a particular coordinate.


Declaration : void moveto(int x, int y);

  1. settextstyle()


settextstyle() function is used to set the font style , direction and font size in a program. There are various types of font style which all are represented by some number in the function.


Declaration: void settextstyle(int font, int direction, int charsize);


  1. outtextxy()


outtextxy() function is used to print something on the graphical console. This function let’s a programmer to print some thing on the graphical console in a particular coordinate. Programmer can choose where to print the output on the graphical interface.


Declaration: void outtextxy(int x, int y, char* textstring);


  1. cleardevice();


cleardevice function clears the screen in graphics mode and sets the current position to (0,0). Clearing the screen consists of filling the screen with current background color.


Declaration :  void cleardevice();

  1. closegraph();

This function is used to close the graphic drive we initialized before.


Declaration : void closegraph();



Along with these functions we also used GetsystemMetrics() function to get the graphical console full screen and GetAsyncKeyState() to read keys from the keyboard.






We made four functions in our program. They are GetStartingDay(), Today(),  Calendar(), and LoadingScreen().  The function of the GetStartingDay() is to fetch the first day of the year. Function of Today() ,  is to show today’s date int the loading screen. Caldendar() function was created to print the calendar in the graphical console. And last the LoadingScreen() function’s work is to show the load screen.

GetStartingDay() : https://drive.google.com/open?id=1MveHuxtsn401bk5qHdXiYYmtjPdEkn8N

Today(): https://drive.google.com/open?id=1ixX27bvyUpgMZ9RSB0y31j9aWWnLi9UZ







After loading screen ends we will have the calendar page. The calendar is in year view. The default year is the current year. To shift to the next year, one need to press the ‘Right Arrow’ button and to shift to the previous year press the ‘Left Arrow’ button. To go to particular year, one must press the ‘Right Shift’ button. Then there will appear another console where one must enter the year which he/she wants to see. After the input, pressing enter one can see the year he/she wants. To see all holidays in that year one has to press ‘Space’ key from the keyboard. To add events on a particular date one have to press ‘Tab’ button from the keyboard. After adding event one can see the date on which the event has been created.  Pressing ‘Esc’ one can exit the graphical console.

This way one can use our ‘Calendar Event Management’ program.



Loading Screen : https://drive.google.com/open?id=197vq6jKFMXRNVF3EcZ2s9XWyt1Y1gJSY


Calendar :












DOWNLOAD: Download our source code here.

Thank You.




Authors: Mridha Imran Kabir(180202), Aldrin Saurov Sarker(180204), Vashkar Kar(180207) and Md. Nazmul Abdal(180225).

Computer Science and Engineering Discipline, Khulna University, Khulna.