I am relatively new to C Programming and have been working for about a week to try and make the following code work.
I have been able to open the file, but when I try to read a line with fgets, I get nothing and a parse error prior to char *num. When I remove the tokenString. . . I compile with no error, but of course, it doesn't read the line. Would someone check the syntax of what I've written and see what I'm missing?
Ptrbook=fopen("Book.dat","r");
if(Ptrbook == NULL) printf("Error opening file\n");
else (printf("File is open\n"));
{ /*Open book assign*/
tokenString = (fgets(buffer,int RECORDLENGTH, Ptrbook));
char *num = strtok(oneline, "\t");
char *name = strtok(NULL, "\t");
char *author = strtok(NULL, "\t");
char *pub = strtok(NULL, "\n");
int i;
printf("%d\n", num);
printf("%s\n", name);
printf("%s\n", author);
printf("%s\n", pub);
fclose(Ptrbook);
Thank you! Your assistance would be greatly appreciated!
Readerwhiz