lvlina_r
جمعه 27 دی 1387, 11:15 صبح
سلام
ببخشين اين كد من مشكلش كجاست كه gets كار نميده
يعني بعد از مقدار دهي هم متغيرم خاليه
struct BOOK *Search_Name()
{
char name [50];
cout <<" \t\tEnter the name of book for searching\n\t";
gets(name);
int i=0,pos,iRecordeNum;
struct BOOK *nb;
FILE *fp=fopen ("book.txt","r+");
fseek( fp, 0, SEEK_END );
pos = ftell( fp);
iRecordeNum = pos / sizeof( struct BOOK);
fseek( fp, 0, SEEK_SET );
nb = new struct BOOK[iRecordeNum];
while(fread (nb,sizeof(struct BOOK),1,fp))
{
if((strcmp(name,(*nb).BookName))==0)
{
cout << "\t\tyour book that u want was found \n\t";
cout << "\t\tthe state of ur book is: "<< (*nb).State << endl;
system("pause");
return nb;
}
}
cout <<"\t\tdosent found\t\n";
system("pause");
}
ببخشين اين كد من مشكلش كجاست كه gets كار نميده
يعني بعد از مقدار دهي هم متغيرم خاليه
struct BOOK *Search_Name()
{
char name [50];
cout <<" \t\tEnter the name of book for searching\n\t";
gets(name);
int i=0,pos,iRecordeNum;
struct BOOK *nb;
FILE *fp=fopen ("book.txt","r+");
fseek( fp, 0, SEEK_END );
pos = ftell( fp);
iRecordeNum = pos / sizeof( struct BOOK);
fseek( fp, 0, SEEK_SET );
nb = new struct BOOK[iRecordeNum];
while(fread (nb,sizeof(struct BOOK),1,fp))
{
if((strcmp(name,(*nb).BookName))==0)
{
cout << "\t\tyour book that u want was found \n\t";
cout << "\t\tthe state of ur book is: "<< (*nb).State << endl;
system("pause");
return nb;
}
}
cout <<"\t\tdosent found\t\n";
system("pause");
}