Student Record System in C with Source Code
The Student Record System in C is a consoled based application created using c programming language. This system is a simple mini project and compiled in Code::Blocks IDE using GCC compiler. In this project you can add student, search student, edit student and delete a student record. This simple mini project for Student Record System in C also includes a downloadable Student Record System Source Code for free, just find the downloadable source code below and click to start downloading. Before you start to click the download now first you must click the Run Quick Scan for secure Download.
This simple mini project for Student Record System creates an external file to store the user’s data permanently to perform file handling operations. This is the features of Student Record System, which is you can add student information, search student information, update student information and can delete student information.
Here, The Student Record System console window screen is basically partitioned into 2 sections – one is static and it doesn’t change, while the other is dynamic and it changes occasionally. The content are coded utilizing different shading color related capacities to make them static.
Anyway if you want level up your knowledge in programming especially C/C++ Programming Language, try this new article I’ve made for you Best C Projects with Source Code for Beginners Free Download 2022.
To start creating a Student Record System In C , make sure that you have a Code Blocks or any platform of C installed in your computer.
ABOUT PROJECT | PROJECT DETAILS |
---|---|
Project Name : | Student Record System |
Project Platform : | C/C++ |
Programming Language Used: | C Programming Language |
Developer Name : | itsourcecode.com |
IDE Tool (Recommended): | Dev-C++/Codeblocks |
Project Type : | Desktop Application |
Database: | Stores data in .DAT file |
Upload Date and Time: | September 21, 2020-2:16 am |
Steps on how to create a Student Record System In C
Time needed: 5 minutes.
Student Record System in C with Source Code
- Step 1: Create a new project.
First open the code blocks IDE and click “create a new project“.
- Step 2: Choose console application.
Second click the “console application” and after that click “next“.
- Step 3: Choose C language.
Third choose “C language” and click “next“.
- Step 4: Name your project.
Fourth name the project you’ve created and click “next” after that click “finish“.
- Step 5: The actual code.
You are free to copy the given source code below or download the downloadable source code given.
This Function is the Student Attributes
In the code given below, which is for the function for creating a student attributes.(C project for Student Record System)
1 2 3 4 5 6 7 8 9 |
struct student{ char stud_id[15]; char stud_name[20]; char stud_address[20]; char stud_parentName[20]; int stud_class; long unsigned int stud_contact_number; }; struct student stu; |
This function is for the set foreground color
In the code given below, which is for the function setting a foreground color for the word use in a console application window system and for printing.(C project for Student Record System)
1 2 3 4 5 6 7 8 9 10 11 12 |
void SetColor(int ForgC) { WORD wordcolor; HANDLE studentHandleOutput = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO conscrbufinfo; if(GetConsoleScreenBufferInfo(studentHandleOutput, &conscrbufinfo)) { wordcolor = (conscrbufinfo.wAttributes & 0xF0) + (ForgC & 0x0F); SetConsoleTextAttribute(studentHandleOutput, wordcolor); } return; } |
This function is for the x and y coordinates
In the code given below. which is for the function of x and y coordinates and you will set the coordinates to 0, 0 to the top left corner of the window.(C project for Student Record System)
1 2 3 4 5 |
COORD coordinates = {0,0}; void x_and_y_coordinates(int x, int y){ coordinates.X = x; coordinates.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coordinates); } |
This function is for the drawing rectangle
In the code given below, which is for the function for drawing a rectangle in a console window and their coordinates.(C project for Student Record System)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
void Drawing_Rectangle(){ int a, b; x_and_y_coordinates(0,0); printf("%c",201); for(a = 1; a < 78; a++){ x_and_y_coordinates(a, 0); printf("%c",205); } x_and_y_coordinates(78,0); printf("%c",187); for(a = 1; a < 25; a++){ x_and_y_coordinates(78, a); if(a == 6){ printf("%c",185); }else{ printf("%c",186); } } x_and_y_coordinates(78, 25); printf("%c",188); for(a = 77; a > 0; a--){ x_and_y_coordinates(a,25); if(a == 35){ printf("%c",202); }else{ printf("%c",205); } } x_and_y_coordinates(0,25); printf("%c",200); for(a = 24; a > 0; a--){ x_and_y_coordinates(0,a); if(a == 6){ printf("%c",204); }else{ printf("%c",186); } } for(a = 1; a < 78; a++){ x_and_y_coordinates(a,6); if(a == 35){ printf("%c",203); }else{ printf("%c",205); } } for(a = 7; a < 25; a++){ x_and_y_coordinates(35,a); printf("%c",186); } } |
This function is for the window title
In the code given below, which is for the function for showing the title window in a console application.(C project for Student Record System)
1 2 3 4 5 6 7 8 9 10 11 |
void window(){ Drawing_Rectangle(); x_and_y_coordinates(28,2); SetColor(35); printf("STUDENT RECORD SYSTEM"); x_and_y_coordinates(20,3); printf("Carlos Hilado Memorial State College"); x_and_y_coordinates(31,4); printf("BINALBAGAN CAMPUS"); x_and_y_coordinates(25,24); SetColor(17); |
This function is for the printing of heading title
In the code given below, which is for the function for showing the heading title after you choose the add student.
1 2 3 4 5 |
void print_heading(const char st[]){ Setting_Color_And_Background(31,28); x_and_y_coordinates(38,8);printf("STUDENT RECORD SYSTEM : %s",st); Setting_Color_And_Background(17,15); } |
This function is for the adding student
In the code given below, which is for the function for adding a new student record in the database.(C project for Student Record System)
1 2 3 4 5 6 7 8 9 10 11 |
void adding_student(){ Reset_Window(); print_heading("Add New Student"); int print = 37; FILE *openfile; openfile = fopen("record.txt","ab+"); SetColor(45); if(openfile == NULL){ MessageBox(0,"Error in Opening file\nMake sure your file is not write protected","Warning",0); }else{ fflush(stdin); x_and_y_coordinates(print,10);printf("ID: ");gets(stu.stud_id); //here you can confirms the ID x_and_y_coordinates(print,12);printf("Name: ");gets(stu.stud_name); x_and_y_coordinates(print,14);printf("Address: ");gets(stu.stud_address); x_and_y_coordinates(print,16);printf("Parent's name: ");gets(stu.stud_parentName); x_and_y_coordinates(print,18);printf("Class: ");scanf("%d",&stu.stud_class); x_and_y_coordinates(print,20);printf("Contact Number: ");scanf("%ld",&stu.stud_contact_number); fwrite(&stu, sizeof(stu), 1, openfile); x_and_y_coordinates(40,22); printf("New Student is Added Successfully"); } SetColor(28); fclose(openfile); return; } |
This function is for the search student
In the code given below, which is for the function for searching a student in a database file. If you search the correct id it will show the record is found if it is wrong it will show there is no record found in the database.(C project for Student Record System)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
void search_student(){ Reset_Window(); print_heading("Search Record"); SetColor(45); char student_id[15]; int isFound = 0; x_and_y_coordinates(37,10);printf("Enter ID to Search: ");fflush(stdin); gets(student_id); FILE *openfile; openfile = fopen("record.txt","rb"); while(fread(&stu,sizeof(stu),1,openfile) == 1){ if(strcmp(student_id,stu.stud_id) == 0){ isFound = 1; break; } } if(isFound == 1){ x_and_y_coordinates(37,12);printf("The record is Found"); x_and_y_coordinates(37,14);printf("ID: %s",stu.stud_id); x_and_y_coordinates(37,15);printf("Name: %s",stu.stud_name); x_and_y_coordinates(37,16);printf("Address: %s",stu.stud_address); x_and_y_coordinates(37,17);printf("Parent's Name: %s",stu.stud_parentName); x_and_y_coordinates(37,18);printf("Class: %d",stu.stud_class); x_and_y_coordinates(37,19);printf("Contact Number: %ld",stu.stud_contact_number); }else{ x_and_y_coordinates(37,12);printf("No record found in the database"); } SetColor(28); fclose(openfile); return; } |
This function is for the modify student
In the code given below, which is for the function for updating the student information.(C project for Student Record System)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
void modify_student(){ Reset_Window(); print_heading("Modify Record"); SetColor(45); char student_id[15]; int isFound = 0, print = 37; x_and_y_coordinates(37,10);printf("Enter ID to Modify: ");fflush(stdin); gets(student_id); FILE *openfile; openfile = fopen("record.txt","rb+"); while(fread(&stu, sizeof(stu),1,openfile) == 1){ if(strcmp(student_id, stu.stud_id) == 0){ fflush(stdin); x_and_y_coordinates(print,12);printf("ID: ");gets(stu.stud_id); x_and_y_coordinates(print,13);printf("Name: ");gets(stu.stud_name); x_and_y_coordinates(print,14);printf("Address: ");gets(stu.stud_address); x_and_y_coordinates(print,15);printf("Parent's name: ");gets(stu.stud_parentName); x_and_y_coordinates(print,16);printf("Class: ");scanf("%d",&stu.stud_class); x_and_y_coordinates(print,17);printf("Contact Number: ");scanf("%ld",&stu.stud_contact_number); fseek(openfile,-sizeof(stu), SEEK_CUR); fwrite(&stu,sizeof(stu), 1, openfile); isFound = 1; break; } } if(!isFound){ x_and_y_coordinates(print, 12);printf("No Record Found"); } fclose(openfile); SetColor(28); return; } |
This function is for the delete student
In the code given below, which is for the function for deleting the student record.(C project for Student Record System)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
void delete_student(){ Reset_Window(); print_heading("Delete Record"); SetColor(45); char student_id[15]; int isFound = 0, print = 37; x_and_y_coordinates(37,10);printf("Enter ID to Modify: ");fflush(stdin); gets(student_id); FILE *openfile, *temporary; openfile = fopen("record.txt","rb"); temporary = fopen("temp.txt", "wb"); while(fread(&stu, sizeof(stu),1,openfile) == 1){ if(strcmp(student_id, stu.stud_id) == 0){ fwrite(&stu,sizeof(stu),1,temporary); } } fclose(openfile); fclose(temporary); remove("record.txt"); rename("temp.txt","record.txt"); x_and_y_coordinates(37,12);printf("The record is sucessfully deleted"); SetColor(28); return; } |
This function is for the main window
In the code given below, which is for the function for the main features of the system.(C project for Student Record System)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
void delete_student(){ Reset_Window(); print_heading("Delete Record"); SetColor(45); char student_id[15]; int isFound = 0, print = 37; x_and_y_coordinates(37,10);printf("Enter ID to Modify: ");fflush(stdin); gets(student_id); FILE *openfile, *temporary; openfile = fopen("record.txt","rb"); temporary = fopen("temp.txt", "wb"); while(fread(&stu, sizeof(stu),1,openfile) == 1){ if(strcmp(student_id, stu.stud_id) == 0){ fwrite(&stu,sizeof(stu),1,temporary); } } fclose(openfile); fclose(temporary); remove("record.txt"); rename("temp.txt","record.txt"); x_and_y_coordinates(37,12);printf("The record is sucessfully deleted"); SetColor(28); return; } |
Downloadable Source Code
Summary
That’s how you create Student Record System in C with Source Code in your projects. You can always expand and try different ways in implementing the Student Record System in C in your C projects. C is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on. C programming is an excellent language to learn to program for beginners. Our C tutorials will guide you to learn C programming one step at a time. In this Student Record System in C with Source Code is free to download and It is easy to understand and manipulate this project and use for education purpose only.
Related Articles
- Library Management System Project In Python and MySQL
- Simple Hospital Management System In C With Source Code
- Library Management System Project in VB.Net With Source Code
- Online Library Management System in PHP Source Code
- Student Management System Project in Python with Source Code
- Online Student Registration System Project in PHP
Inquiries
If you have any questions or suggestions about Student Record System in C with Source Code , please feel free to leave a comment below.