Guest User

Untitled

a guest
Apr 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.27 KB | None | 0 0
  1. void bookInfo(char *path, int ranking[MAX_BOOKS], int category[MAX_BOOKS], char author[MAX_BOOKS][BIG], char publisher[MAX_BOOKS][BIG], int price[MAX_BOOKS], char description[MAX_BOOKS][BIG])
  2. {
  3.     {
  4.         int i;
  5.         char buffer[BIG];
  6.         FILE *bookFile;
  7.         bookFile = fopen(path, "r");
  8.  
  9.         if(bookFile == NULL)
  10.         {
  11.             printf("Unable to open file!\n");
  12.             system("exit");
  13.         }
  14.         for(i=0; !feof( bookFile ); i++)
  15.         {
  16.             fgets( buffer, sizeof(buffer), bookFile);
  17.             /* /// This is so frustrating!
  18.             4 1,ZERO DAY, by David Baldacci (Grand Central Publishing, $27.99) A military investigator uncovers a conspiracy.
  19.             (ranking, category, title, author, publisher, price, description)(int int string string int string)
  20.             */
  21.             sscanf(buffer, "%i %i%[^,],%[^,], by %[^(](%[^,], $%d%[^)]) %s", &ranking[i], &category[i], author[i], publisher[i], &price[i], description[i]);
  22.  
  23.             printf("%p %p %p %p %p %p\n", ranking[i], category[i], author[i], publisher[i], price[i], description[i]);
  24.             printf("%d %d %s %s %d %s\n", ranking[i], category[i], author[i], publisher[i], price[i], description[i]);
  25.  
  26.  
  27.  
  28.         }
  29.         fclose(bookFile);
  30.     }
  31. }
Add Comment
Please, Sign In to add comment