I am trying to read from a file , that contains.
"15668942" "TOYOTA" "ENGINE PISTON" 12.50 8
"68465245" "NISSAN" "STARTER" 50.20 14
"14134455" "MITSUBISHI" "STEERING WHEEL" 20.00 0
"31457645" "SUBARU" "TURBO" 3000.00 5
$$$$$$$$$$
I tried using sscanf. When the files reaches $$$$$ it should stop reading from the file. I havent able to get the $$$ to work as yet so i used NULL.
My problem is 2 things.
1) When I use sscanf and i Print it, it got the number correct, and the word toyota correct. When it came to engine piston, it took up to "engine " and used the rest for the double variable it seems to me because the output for the double and integer are crazy numbers.
Code:
while(fgets(line,100,in)!=NULL)
{
sscanf(line, "%s %s %s %e %d",number,name,description,&unit_price,&quantity_in_stock);
printf("%s %s %s %e %d\n",number,name,description,unit_price,quantity_in_stock);
}
2) When I do get the values and strings in their variables, I also get the quotes. I would like to get rid of those quotes. I tried using strtok but I am getting trouble for it to take off the " because of the syntax. For example
Code:
resule=strtok(name,""");
I know this does not work lol.
Any advice.