C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - Point Out Errors (Q.No. 3)
3.
Point out the error in the program?
#include<stdio.h>

int main()
{
    FILE *fp;
    fp=fopen("trial", "r");
    fseek(fp, "20", SEEK_SET);
    fclose(fp);
    return 0;
}
Error: unrecognised Keyword SEEK_SET
Error: fseek() long offset value
No error
None of above
Answer: Option
Explanation:
Instead of "20" use 20L since fseek() need a long offset value.
Discussion:
13 comments Page 2 of 2.

Nitesh said:   8 years ago
Please explain the program.

CompeQ said:   7 years ago
fseek(fp, "20", SEEK_SET);

The correct answer should be: Invalid conversion from const char* to long int.

G.sai nikhitha said:   5 years ago
What is the meaning of
fseek(fp,-2,SEEK_CUR);


Post your comments here:

Your comments will be displayed after verification.