my following program is SUPPOSED TO read in following contents from INPUT.txt file
Code:
mystery sherlock_holmes conan_doyle b 0 1 jokes what_a_gag jose_johnson b 0 1 magazines expat alan b 0 1 comics archies archies b 0 1 comedy tom_and_jerry c 0 1
Code:
#include<stdio.h>
#include<string.h>
#include<math.h>
struct books
{
char title[100];
char author[50];
char subject[50];
char type;
int borrower; // 0 no one borrowed
int available;
};
struct size
{
int total_books;
int t_m;
};
void upload(struct books book[1000] ,struct size n);
int main()
{
struct size n;
struct size book[1000];
upload(book,n);
return 0;
}
void upload(struct books book[1000] ,struct size n)
{
int i=0;
FILE *f;
f = fopen("INPUT.txt","r");
if(f == NULL)
{
printf("\n\tERROR : UNable to open file....\n");
return;
}
while( (i < 4) && (fscanf(f,"%s%s%s%c%d%d\n",&(book[i].subject),&(book[i].title),&(book[i].author),&(book[i].type),&(book[i].borrower),&(book[i].available) ) == 6))
{
i++;
printf("%s %s %s %c %d %d\n", (book[i].subject),(book[i].title),(book[i].author),(book[i].type),(book[i].borrower),(book[i].available) );
}
fclose(f);
return;
}
there is also a warning for upload(book,n); -- integer to pointer or something like that

