Scroll Down to See All
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1yn



Function Details : fsetpos

intfsetpos(FILE * stream,const fpos_t * pos) ;

Return Type : int

Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
Read about return values of fsetpos function .

1st Parameter Type : FILE *

Pointer to FILE structure for file operations

1st Parameter

Pointer to the file stream for which the file position is to be set

2nd Parameter Type : const fpos_t *

A pointer to a constant `fpos_t` object, used to store or set a file position. The `const` qualifier ensures that the pointed-to position cannot be modified through this pointer.

2nd Parameter

Pointer to an `fpos_t` object containing the position to set for the file stream

Read more about parameters of fsetpos in parameters section
The fsetposfunction in C language Sets the file position of the stream based on the position given by fpos_t.
The fsetpos function sets the file position indicator for the stream pointed to by stream according to the value of the object pointed to by pos, which is a pointer to an fpos_t object that specifies the position. The function is typically used in conjunction with fgetpos to restore a position previously obtained. On successful completion, the function clears the end-of-file indicator for the stream and undoes any effects of ungetc on the same stream.
The fsetposfunction takes 2 parameters:
  • FILE * `stream`: Pointer to the file stream for which the file position is to be set
  • const fpos_t * `pos`: Pointer to an `fpos_t` object containing the position to set for the file stream
Sets the file position of the specified file stream to the location specified by `pos`. The `fpos_t` object should have been obtained using `fgetpos`. Returns `0` on success or a nonzero value on error.
The fsetpos function return value :
  • Returns 0 if successful, or non-zero if an error occurred

Output

This example demonstrates the basic usage of `fsetpos` in conjunction with `fgetpos`. It reads the first two lines of a file, saves the position after the first line, and then restores that position to read the second line again.