Knowee
Questions
Features
Study Tools

Which of the following functions changes the position of file pointer andreturns its new position?

Question

Which of the following functions changes the position of file pointer andreturns its new position?

🧐 Not the exact question you are looking for?Go ask a question

Solution

The function that changes the position of the file pointer and returns its new position is the fseek() function in C programming. Here's how it works:

  1. The fseek() function is declared in the stdio.h header file. It is used to move the file pointer to a specific location in the file.

  2. The syntax of the fseek() function is as follows: int fseek(FILE *pointer, long int offset, int position);

  3. The 'pointer' is the pointer to the file where the file pointer needs to be moved.

  4. The 'offset' is the number of characters to move the file pointer. If the offset is negative, the file pointer moves to the backward direction.

  5. The 'position' is the starting point where the file pointer to be moved. It has three values:

    • SEEK_SET: It denotes the beginning of the file.
    • SEEK_CUR: It denotes the current position of the file pointer.
    • SEEK_END: It denotes the end of the file.
  6. The fseek() function returns zero if the operation is successful. If the operation fails, it returns a non-zero value.

  7. After the fseek() function is called, you can use the ftell() function to get the current position of the file pointer. The ftell() function returns the current position of the file pointer.

This problem has been solved

Similar Questions

Which of the following function gives the current position of the file pointer?*1 pointfseek()ftell()rewind()fread()

In C++, when accessing files randomly, which function is used to get current pointer position inside a file?

_______________________ resides within the file and moves with the file, not changing unless the contents of the file are altered.

What does fp point to in the program ? #include<stdio.h> int main() { FILE *fp; fp=fopen("trial", "r"); return 0; } ans. The first character in the file A structure that contains a char pointer that points to the first character of a file. The name of the file. The last character in the file.

Which of the following statements about pointers is true?

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.