main()
{
FILE *fs;
char c[10];
fs = fopen(“source.txt”, ”r”); /* source.txt exists and
contains “Vector Institute” */
fseek(fs,0,SEEK_END);
fseek(fs,-3L,SEEK_CUR);
fgets(c,5,fs);
puts(c);
}



main() { FILE *fs; char c[10]; fs = fopen(“source.txt”, ”r”); /* source.txt exists and ..

Answer / sahoo845

it prints ute.
SEEK_END moves the pointer to end of the file.
SEEK_CUR moves the pointer 3 places back(-3L). Nw the pointer is at u.
gets() tries to fetch 5 characters from the present position of pointer but can fetch only 3 characters as it reaches end of file.
puts() prints the characters i.e. ute.

Is This Answer Correct ?    15 Yes 0 No

Post New Answer

More C Interview Questions

what is use of loop?

10 Answers   Infosys,


What is the difference between the = symbol and == symbol?

0 Answers  


Why are all header files not declared in every c program?

0 Answers  


How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

2 Answers  


how to make program without <> in library.

1 Answers   ADITI,






How can I sort a linked list?

0 Answers  


what is the output of the program?? #include<stdio.h> main ( ) { int a=010,sum=0,tracker: for(tracker=0;tracker<=a;tracker++) sum+=tracker; printf(“ %d\n”,sum); } what is the difference between a=10 and a=010??

3 Answers   Oracle,


What is difference between main and void main?

0 Answers  


Can you think of a logic behind the game minesweeper.

0 Answers  


Do you know what is the purpose of 'extern' keyword in a function declaration?

0 Answers  


Juxtapose the use of override with new. What is shadowing?

1 Answers  


to find the closest pair

0 Answers   Infosys,


Categories