C program to read a record from text file and store it in an array.

#include<stdio.h>
#include<conio.h>
void main(){
FILE *fp;
char msg[100];
int i=0;
clrscr();
fp=fopen ("xyz.txt","r+");
if (fp==NULL){
printf("opration failed!!\n");
getch();
exit(0);
}
while (feof(fp)){
msg[i++]=fgetc(fp);
}
//fgets(msg,100,fp);
getch();
fclose(fp);
}

No comments:

Post a Comment