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);
}

Comments

Popular posts from this blog

C Language Topics in Hindi and English

C language IMP Questions for BSc/BA/BCom/BCA/BE/BTech/MSc/MCA (CS/IT) I year students