Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Here is a program in C that illustrates the use of fscanf() to read a text file:

#include <stdio.h>
#include <stdlib.h>
int main()
{

printf("Welcome to DataFlair tutorials!

");

char character;
FILE *fpointer;

if ((fpointer = fopen("C:program.txt","r")) == NULL)
{
printf("Error! The file does not exist.");
exit(0);
}
fscanf(fpointer,"%c", &character);
printf("The character is: %c", character);
fclose(fpointer);
return 0;
}
 
PREVIOUS NEXT
Tagged: #Here #program #C #illustrates #read #text
ADD COMMENT
Topic
Name
6+9 =