Saturday, January 28, 2012

Mini project student database system in c++ source code download

This is simple student information system project.Wher you can do following things 1. Add    Records
          2. List   Records
          3. Modify Records
          4. Delete Records
          5. Exit   Program
to store data file is used. Download project from GitHub.

Here is the source code,compile it in code::blocks
 
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <conio.h>
#include <iomanip>
 
using namespace std;
int main() {
    FILE *fp, *ft;
    char another, choice;
 
struct student {
        char first_name[50], last_name[50];
        char course[100];
        int section;
    };
 
    struct student e;
    char xfirst_name[50], xlast_name[50];
    long int recsize;
 
    fp=fopen("users.txt","rb+");
 
    if (fp == NULL) {
        fp = fopen("users.txt","wb+");
 
        if (fp==NULL)
        {
             puts("Cannot open file");
             return 0;
        }
    }
 
 
 recsize = sizeof(e);
 
 while(1) {
     system("cls");
 
     cout << "\t\t====== STUDENT INFORMATION SYSTEM ======";
     cout <<"\n\n                                          ";
     cout << "\n\n";
     cout << "\n \t\t\t 1. Add    Records";
     cout << "\n \t\t\t 2. List   Records";
     cout << "\n \t\t\t 3. Modify Records";
     cout << "\n \t\t\t 4. Delete Records";
     cout << "\n \t\t\t 5. Exit   Program";
     cout << "\n\n";
     cout << "\t\t\t Select Your Choice :=> ";
     fflush(stdin);
     choice = getche();
     switch(choice)
     {
      case '1' :
            fseek(fp,0,SEEK_END);
            another ='Y';
            while(another == 'Y' || another == 'y')
            {
                  system("cls");
                cout << "Enter the Firt Name : ";
                cin >> e.first_name;
                cout << "Enter the Last Name : ";
                cin >> e.last_name;
                cout << "Enter the Course    : ";
                cin >> e.course;
                cout << "Enter the Section   : ";
                cin >> e.section;
                fwrite(&e,recsize,1,fp);
                cout << "\n Add Another Record (Y/N) ";
                fflush(stdin);
                another = getchar();
            }
            break;
   case '2':
            system("cls");
           rewind(fp);
           cout << "=== View the Records in the Database ===";
           cout << "\n";
           while (fread(&e,recsize,1,fp) == 1){
           cout << "\n";
           cout <<"\n" << e.first_name << setw(10)  << e.last_name;
           cout << "\n";
           cout <<"\n" <<e.course <<  setw(8)  << e.section;
           }
           cout << "\n\n";
           system("pause");
           break;
 
   case '3' :
            system("cls");
          another = 'Y';
          while (another == 'Y'|| another == 'y')
          {
              cout << "\n Enter the last name of the student : ";
              cin >> xlast_name;
 
            rewind(fp);
            while (fread(&e,recsize,1,fp) == 1)
            {
                if (strcmp(e.last_name,xlast_name) == 0)
                {
                cout << "Enter new the Firt Name : ";
                cin >> e.first_name;
                cout << "Enter new the Last Name : ";
                cin >> e.last_name;
                cout << "Enter new the Course    : ";
                cin >> e.course;
                cout << "Enter new the Section   : ";
                cin >> e.section;
                fseek(fp, - recsize, SEEK_CUR);
                fwrite(&e,recsize,1,fp);
                break;
                }
                else
                cout<<"record not found";
            }
            cout << "\n Modify Another Record (Y/N) ";
                fflush(stdin);
                another = getchar();
            }
            break;
 
 
     case '4':
       system("cls");
           another = 'Y';
          while (another == 'Y'|| another == 'y')
          {
              cout << "\n Enter the last name of the student to delete : ";
              cin >> xlast_name;
 
              ft = fopen("temp.dat", "wb");
 
              rewind(fp);
              while (fread (&e, recsize,1,fp) == 1)
 
                 if (strcmp(e.last_name,xlast_name) != 0)
                {
                    fwrite(&e,recsize,1,ft);
                }
                fclose(fp);
                fclose(ft);
                remove("users.txt");
                rename("temp.dat","users.txt");
 
                fp=fopen("users.txt","rb+");
 
                cout << "\n Delete Another Record (Y/N) ";
                fflush(stdin);
                another = getchar();
              }
 
              break;
 
              case '5':
              fclose(fp);
              cout << "\n\n";
              cout << "\t\t     THANK YOU FOR USING THIS SOFTWARE";
              cout << "\n\n";
              exit(0);
          }
     }
 
 
system("pause");
return 0;
}

41 comments:

  1. i want a c project on faculty feedback system

    ReplyDelete
  2. this program have 14 errors and 1 warning ... i am unable to run this program

    ReplyDelete
    Replies
    1. hey i need u i have some qu for you

      Delete
  3. All the program of c and c++ is compile in gcc compiler and codeblocks IDE. so , if you compile this program in turbo c then you will get error

    ReplyDelete
  4. if i compile it in visual studio 2010 it shows me 8 errors .... how do i overcome it ??

    ReplyDelete
  5. is this gcc compiler is diffrent copiler??

    ReplyDelete
    Replies
    1. could anyone give me the link to download gcc

      Delete
  6. How you compile I don't Know? There is 6 warning but no error. You can download the project file with source code compile in visual studio 2010 for this link https://www.dropbox.com/sh/6iurx6sgps4oloc/vf--GyGi7x/studentDatabase.rar

    ReplyDelete
  7. hey bro. Cool code. Compiled it with g++ in geany. It gives this error:

    student.cpp:23: warning: unused variable 'xfirst_name'

    ...and sure enough you declared it but never used it. What's it for?

    ReplyDelete
  8. Thank you for posting this. It worked for me. No errors. I used dev c/c++
    Once more thanks :)

    ReplyDelete
  9. error :Declaration syntax error at line no 8.please give me solution for it.

    ReplyDelete
  10. pls i need the flowchart for this program

    ReplyDelete
  11. I wanna this project like class and use get and set ......how can help me ???

    ReplyDelete
  12. it gives the following error in visual studio 2012:
    Error 1 error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. c:\users\sheikh noman mehmood\documents\visual studio 2012\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 27

    ReplyDelete
  13. i want coding for timetable management system.....

    ReplyDelete
    Replies
    1. can u get me the code for this title(Time table Mgmt System).

      Delete
  14. guys plz mention output :( no o/p no marks

    ReplyDelete
  15. ur idiotic project has 24 errors

    ReplyDelete
  16. is the personal information mangement and employ mangement system same thing?
    plz tell me...

    ReplyDelete
  17. why is it showing the all questions when you want to Add another record ?

    ReplyDelete
  18. Hey,that's really cool!But there's an error.When I want to delete a record,it displays the "Last Name" text and "Continue "text together.I think you need to fix it.

    ReplyDelete
  19. Master of Computer Application is a post graduation degree with 3 years of duration. There are many top colleges that provide MCA course. One need to clear the entrance exam for the admission in to this course.
    Top MCA Colleges India Thanks for sharing.

    ReplyDelete
  20. Do you have the file "users.txt" to open and manipulate with this source code? I'm not sure how to make this text file correctly on my own so it could be used in the code properly.

    ReplyDelete
  21. i want c++ project on feed back mangement system in which parents give feedback and the computer will tell the summary of their feedback that the school is good the school is clean e.t.c

    ReplyDelete
  22. It gives error at 8 line declaration syntax error

    ReplyDelete
  23. No classes. The only C++ here is cout and cin. The rest is C. Not even C++ styles (//) comments.

    ReplyDelete
  24. There is no Error neither the Warning.
    but there is a bug
    that is , if we insert course name in more than a word like "Information technology"
    than it keeps on repeating this second word in all next required informations.
    Otherwise the code is Good.

    ReplyDelete
  25. If you use "cout" this doesn't mean C++.
    C++ is object oriented. What you have write is C and same elements of C++.

    ReplyDelete
  26. Do u have "Hospital Registration and Database" dev C++? or can you help creating it? :) Thanks for this awesome codes.

    ReplyDelete
  27. how to delete student info using roll number? deleting from last name is complicated
    because if many person have same last name then all the data are deleted plz help to fix this :) waiting for your positive response

    ReplyDelete
  28. Great!! No Errors! Nice Project

    ReplyDelete
  29. can someone explain the codes one by one please? :(

    ReplyDelete