C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - Point Out Errors (Q.No. 3)
Point out the error in the program?

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

Vishal Babasaheb rahikar said:   5 years ago
Syntax for feel is;

fseek(file*stream,long offset value,int whence);
Here while providing offset value provide as 20L not 20 ,3rd argument have 3 macros SEEK_SET,SEEK_CUR,SEEK_END.

SEEK_SET means character seeking starts from the beginning of file, SEEK_CUR means starts seeking from last accessed word and SEEK_END means starts from end towards the beginning.

Ravi Sankar said:   10 years ago
seek_set = Cursor moves to first letter of the file .
seek_end = Cursor moves to last letter of the file.
seek_cur = Cursor starts when ever we accessed last world.

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

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

Kirubashini said:   8 years ago
I don't understand this line:

fseek(fp, "20", SEEK_SET);

Please explain me.

Babita said:   1 decade ago
It seeks a specified place within a file and modify it

MADHU said:   6 years ago
I can't understand. Please explain this program.

G.sai nikhitha said:   4 years ago
What is the meaning of

Divya said:   1 decade ago
Is extension of the file "trial" necessary?

Prashant said:   1 decade ago
What is seek_set()? can anyone explain.

Kunal said:   1 decade ago
What is the use of fseek() ?

Post your comments here:

Your comments will be displayed after verification.