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);
}
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 |
Is it possible to execute code even after the program exits the main() function?
Write a program using two-dimensional array that lists the odd numbers and even numbers separately in a 12 input values.
What is the difference between fread and fwrite function?
Explain how do you print only part of a string?
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
What is indirection?
Write the Program to reverse a string using pointers.
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
Do you know null pointer?
Explain heap and queue.
Why clrscr is used in c?
What is meant by global static? why we have to use static variable instead of Global variable