Table of Contents
This guide covers function ftell ()() in c with practical context and easy-to-follow details. Use it to understand the subject and apply the information confidently.
Declare Ftell ()() Function in C
Below is the declaration for ftell () function in C:
long int ftell ( FILE * stream )
Parameters
Stream - This is the pointer to a FILE object that identifies the Stream.
Returns the value
This function returns the current value of position indicator. If an error occurs, -1 is returned, and the global variable errno is set to a positive value.
For example
The following program C illustrates the usage of the ftell () function in C:
#include int main () { FILE * fp ; int len ; fp = fopen ( "baitapc.txt" , "r" ); if ( fp == NULL ) { perror ( "Xay ra loi khi mo file!!!" ); return (- 1 ); } fseek ( fp , 0 , SEEK_END ); len = ftell ( fp ); fclose ( fp ); printf ( "Tong kich co cua baitapc.txt = %d bytesn" , len ); return ( 0 ); }
Suppose we have the bait. Txt file with the following content:
Hoc C co ban va nang cao tai QTM !!!
Compiling and executing the above program will produce the following result if the file has the above content, otherwise it will give different results depending on the content of the file.
According to Tutorialspoint
Previous post: Function fsetpos () in C
Next lesson: Function fwrite () in C
FAQ
What should I check before following these steps?
Confirm device and software compatibility, save important data, and make sure you have the required permissions, files, and account access.
Why might the process not work?
Common causes include outdated software, missing permissions, incompatible hardware, an unstable connection, or completing a step in the wrong order.
Can I undo the changes if necessary?
That depends on the tool or setting. Use built-in restore options when available, keep a backup, and record the original configuration first.

Reader Comments 0
Sign in with email or Google to join the discussion.