|
|
小妹遇到一个问题,想请教哥哥姐姐帮忙。。。
请问为什么print不到publc_name,ISBN,state? 谢谢!
#include <stdio.h>
int main ()
{
FILE* spBook;
char strngBook[460];
char callnumber[7];
char author[128];
char publc_date[11];
char title[128];
char publc_loc[81];
char publc_name[81];
char ISBN[13];
char state[11];
//check file open successfully
spBook = fopen("Items_Book.txt", "r");
if(!spBook)
printf("Error openning Items_Book.txt file.\n");
fgets(strngBook, sizeof(strngBook), spBook);
sscanf(strngBook, "%7s %128s %11s %128s %81s %81s %13s %11s", callnumber, author, publc_date, title, publc_loc, publc_name, ISBN, state);
printf("%s %s %s %s %s %s %s %s", callnumber, author, publc_date, title, publc_loc, publc_name, ISBN, state);
closeBook = fclose(spBook);
if(closeBook==EOF)
printf("Could not close Items_Book.txt file.\n");
return 0;
}
__________________________________________________________________________________________________________
Items_Book.txt
B111111 Alberg H.T. 17/2/1997 Computer Science1 Ireland Prentice Hall 0-11-111111-1 ON_SHELF (\n)
(all in one line) |
|