text file reading
text file reading
hi
how to read a line and an item from a text file using C program please help
1 Dec 06, 6:46AM
Dear Sumith,
To read a line form a file using C programing language you can use fgetc().
Which gets character from a file. Here is an example. Pls. feel free if u need. I have used Turbo 3.0.
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *myfile;
char ch;
myfile=fopen("sample.txt","r"); //The file you want to read is "sample.txt".
while(1) {
ch=fgetc(myfile); if(ch==EOF) break; printf("%c", ch); } getch(); }//you can manipulate the character which is collected in ch. You can display it on standard console or in some other file.
//Hope you got your answer.
Login