im pretty new to programming i had this issue, i have writtern this program to read the formated data from a text file named "num.txt" and the info in that file is :
raju : 12
lokesh : 11
dinesh : 10
#include<stdio.h>
int main()
{
FILE *f1;
f1=fopen("D:/num.txt","r");
int mark;
char name[20];
while(!feof(f1))
{
fscanf(f1,"%[^:]:%d",name,&mark);
printf("the %s marks are %d",name,mark);
}
}
and the output put is:
the raju marks are 12th
lokesh marks are 11the
dinesh marks are 10
Here, i can clearly understood that the first '\n'(0f the first line) in the text file is being in the buffer and been taken by the second %s string,now i tried to flush the buffer by using the fflust & also thw while(getchar()) method but no use. My main problem here is lack of undersanding of , how the new line '\n' is actually kept in the text file, for every new line.And how newlines are handled..
Im sorry that, i may have not expressed the question in a proper way but as i said i new and learning even ENGLISH.