I have an input text to read with fscanf function. I can read some of lines. But, I could not read a line. Can you help?
My input.txt:
54,ZeynepKucuk,62-46-59
62,OsmanBuyuk
46,GulayEr,25-23-32-14
I can read first and third line. But I have some problem with second line because its third position is empty.
But I can read surely if the input is like below
54,ZeynepKucuk,62-46-59
62,OsmanBuyuk,0
46,GulayEr,25-23-32-1
Some part of my code below
Code:int id; char name[100]; char friends[100]; FILE*dosya = fopen("input.txt","r"); struct node *root = NULL; while(fscanf(dosya,"%d,%[^,],%s,%[^,],%s\n",&id, name, friends)==3){ root = insertNewUser(root, id, name, friends); }
After adding to tree my datas and print, expected output is:
54,ZeynepKucuk,62-46-59
62,OsmanBuyuk
46,GulayEr,25-23-32-1