نوع فایل

فرمت

سورس زبان سی پلاس پلاس

CPP , EXE

پیش نمایش از سورس کد پروژه

#include <iostream.h>
#include <conio.h>
#include <fstream.h>
#include <process.h>
#include <stdio.h>
#include <string.h>
#include <iomanip.h>
#define fname “student.dat”
struct student
{
unsigned int id;
short stid;
char name[50];
char family[50];
char number[20];
char address[100];
};

void showinfo(char[]);
void add();
int existid(unsigned int);
void deletest();
void seeinfo();
void search();
void about();
void drawmainmenu(int);

int main()
{
clrscr();
int keyboard_read=0;
int PASS=1;
int currpos=1;
drawmainmenu(1);
while (PASS)
{
drawmainmenu(currpos);
keyboard_read=getch();
switch(keyboard_read)
{
case 72: //Up
if(currpos > 1)
currpos=currpos-1;
else
currpos=6;
drawmainmenu(currpos);
break;
case 80: //Down
if(currpos >= 1 && currpos < 6)
currpos=currpos+1;
else
currpos=1;
drawmainmenu(currpos);
break;
case 13:
if (currpos==1)
{
add();
break;
}
else if (currpos==2)
{
search();
break;
}
else if (currpos==3)
{
deletest();
break;
}
else if (currpos==4)
{
seeinfo();
break;
}
else if (currpos==5)
{
about();
break;
}
else if(currpos==6)
{
PASS=0;
break;
}
}
}
return 0;
}

void showinfo(char message[])
{
textbackground(BLACK);
clrscr();
textcolor(RED);
gotoxy(1,1);
cprintf(message);
textcolor(GREEN);
gotoxy(1,4);
cout<<“Student Number : “;
cprintf(” “);
textbackground(BLACK);
textcolor(GREEN);
gotoxy(1,6);
cout<<“Name : “;
cprintf(” “);
textbackground(BLACK);
textcolor(GREEN);
gotoxy(1,8);
cprintf(“Family : “); textcolor(WHITE);textbackground(BLUE);cprintf(” “);
textbackground(BLACK);
textcolor(GREEN);
gotoxy(1,10);
cprintf(“id : “); textcolor(WHITE);textbackground(BLUE);cprintf(” “);
textbackground(BLACK);
textcolor(GREEN);
gotoxy(1,12);
cprintf(“Number : “); textcolor(WHITE);textbackground(BLUE);cprintf(” “);
textbackground(BLACK);
textcolor(GREEN);
gotoxy(1,14);
cprintf(“Address : “); textcolor(WHITE);textbackground(BLUE);cprintf(” “);
}

void add()
{
char chkey;
student st;
ofstream save;
showinfo(“Add Student Information”);
gotoxy(18,4);
cin >> st.id;
gotoxy(18,6);
gets(st.name);
gotoxy(18,8);
gets(st.family);
gotoxy(18,10);
cin >> st.id;
gotoxy(18,12);
gets(st.number);
gotoxy(18,14);
gets(st.address);
gotoxy(1,17);
if (existid(st.id)==0)
{
textbackground(BLACK);
textcolor(YELLOW);
cprintf(“Do You Want To Save This Student Information (y/n) : “);
chkey=getche();
if (chkey==’y’ || chkey==’Y’)
{
save.open(fname,ios::app | ios::binary);
save.write((char*) &st,sizeof(st));
save.close();
}
}
else
{
textbackground(BLACK);
textcolor(RED);
cprintf(“This Student Number Is Exist !”);
getch();
}
textbackground(BLACK);
textcolor(7);
}

StudentProj

======