I/O Functions in C
I/O, file handling, directory control, and buffer manipulation functions in C programming with descriptions are listed below. You can use the following functions to work with values.
I/O Functions
Function |
Use |
Close |
Closes a file. |
fclose |
Closes a file. |
feof |
Detects end-of-file. |
fgetc |
Reads a character from a file. |
fgetchar |
Reads a character from keyboard (function version). |
fgets |
Reads a string from a file. |
fopen |
Opens a file. |
fprintf |
Writes formatted data to a file. |
fputc |
Writes a character to a file. |
fputchar |
Writes a character to screen (function version). |
fputs |
Writes a string to a file. |
fscanf |
Reads formatted data from a file. |
fseek |
Repositions file pointer to given location. |
ftell |
Gets current file pointer position. |
getc |
Reads a character from a file (macro version). |
getch |
Reads a character from the keyboard. |
getche |
Reads a character from keyboard and echoes it. |
getchar |
Reads a character from keyboard (macro version). |
gets |
Reads a line from keyboard. |
inport |
Reads a two-byte word from the specified I/O port. |
inportb |
Reads one byte from the specified I/O port. |
kbhit |
Checks for a keystroke at the keyboard. |
lseek |
Repositions file pointer to a given location. |
open |
Opens a file. |
outport |
Writes a two-byte word to the specified I/O port. |
outportb |
Writes one byte to the specified I/O port. |
printf |
Writes formatted data to screen. |
putc |
Writes a character to a file (macro version). |
putch |
Writes a character to the screen. |
putchar |
Writes a character to screen (macro version). |
puts |
Writes a line to file. |
read |
Reads data from a file. |
rewind |
Repositions file pointer to beginning of a file. |
scanf |
Reads formatted data from keyboard. |
sscanf |
Reads formatted input from a string. |
sprintf |
Writes formatted output to a string. |
tell |
Gets current file pointer position. |
write |
Writes data to a file. |
File Handling Functions
Function |
Use |
remove |
Deletes file. |
rename |
Renames file. |
unlink |
Deletes file. |
Directory Control Functions
Function |
Use |
chdir |
Changes current working directory. |
getcwd |
Gets current working directory. |
fnsplit |
Splits a full path name into its components. |
findfirst |
Searches a disk directory. |
findnext |
Continues findfirst search. |
mkdir |
Makes a new directory. |
rmdir |
Removes a directory. |
Buffer Manipulation Functions
Function |
Use |
memchr |
Returns a pointer to the first occurrence, within a specified number of characters,
of a given character in the buffer. |
memcmp |
Compares a specified number of characters from two buffers. |
memcpy |
Copies a specified number of characters from one buffer to another. |
memicmp |
Compares a specified number of characters from two buffers without regard to the
case of the characters. |
memmove |
Copies a specified number of characters from one buffer to another. |
memset |
Uses a given character to initialize a specified number of bytes in the buffer. |