#include<stdio.h>
#include<conio.h>
void main()
{
char name[50];
FILE *fptr;
fptr=fopen("D:\\sentence.txt","r");
fscanf(fptr,"%s",name);
printf("%s",name);
fclose(fptr);
getch();
}
OUTPUT:
If the file sentence.txt inside D drive does not exist, this program will return NULL.
If not, the first string inside that file will be read and displayed on console.
No comments:
Post a Comment