0

I want to make a function that searches my library.txt and returns a prinf output on whether the book exists within the file

void search(FILE *fptr){ FILE *fptr2; fptr = fopen("library.txt","r"); if (fptr == NULL){        printf("Error! opening file"); } fptr2 = fopen("output.txt","a+"); if (fptr2 == NULL){        printf("Error! opening file"); } char s[80]; int i; struct book b; struct library l; printf("Enter title of book.\n"); scanf("%s",&s); fscanf(fptr,"%s %d",&b.title,&l.num_books); if(fgets(s[80],l.num_books,*b.title)==1){    printf("the book %s is currently available.\n",s); } if(fgets(s[80],l.num_books,b.title)!=1){     printf("the book %s is currently not available.\n",s);    } fclose(fptr); fclose(fptr2); }

16th Dec 2018, 8:25 AM
Keith Owino
Keith Owino - avatar
2 Respostas
+ 1
You should use some regex library, that would be much better for searching.
19th Dec 2018, 5:30 PM
🇵🇰 Danish Khan 🇵🇰
🇵🇰 Danish Khan 🇵🇰 - avatar
0
Stfu
27th Dec 2018, 11:50 AM
Zahir Sholgami