Fseek on C problem
Posted
by Pedro
on Stack Overflow
See other posts from Stack Overflow
or by Pedro
Published on 2010-04-22T23:09:14Z
Indexed on
2010/04/22
23:13 UTC
Read the original article
Hit count: 255
Filed under:
c
i'm testing this code, but doesn't work, it always says that an error occurred :S
int main(int argc, char **argv) {
FILE *file_pointer;
file_pointer = fopen("text.txt","r");
if(fseek(file_pointer, 0, -1)) {
puts("An error occurred");
}
else {
char buffer[100];
fgets(buffer, 100, file_pointer);
puts("The first line of the file is:");
puts(buffer);
}
fclose(file_pointer);
return 0;
}
© Stack Overflow or respective owner