dimanche 19 avril 2015

sscanf input not working

I have tab seperated records like this



1000 Muhammad Aashir 0213-4211685 123456 0


first I have read the line by using fgets and now i am trying to extract contents by using sscanf, but there is an unexpected problem... please help I am beginner


here is the code



char buffer[SIZE];Account req;
while(fgets(buffer,SIZE,fptr))
{
cout<<endl<<buffer<<endl;
sscanf(buffer,"%d\t%s\t%s\t%s\t%ld\n",&req.acc_num,req.name,req.mobileno,req.pass,&req.acc_bal);
cout<<endl<<req.pass;
}


output of BUFFER is same as the record line


but after extracting values, when I am displaying the 'req.pass' the value is incorrect


req.pass is displaying '0213-4211685' but it has to display '123456'


Aucun commentaire:

Enregistrer un commentaire