Input/Output and File Handling in C

Input/Output and File Handling in C

In this lesson, you will learn about the different types of input/output and file handling in C programming. Input/output is used to get data from the user or send data to the user. File handling is used to read and write data from files. You will learn how to open and close files, as well as how to read and write data from them.

Example

#include <stdio.h> 

int main() 
{ 
    FILE *fp; 
    char str[60]; 
  
    fp = fopen("test.txt", "w+"); 
    fprintf(fp, "Hello World!"); 
  
    rewind(fp); 
    fscanf(fp, "%s", str); 
  
    printf("%s", str); 
    fclose(fp); 
  
    return 0; 
} 

Output

Hello World!

Leave a Reply