Reading spaces from file
I know how to read most information from file for example if I have this in a file:
Phillips Head Screwdriver;5;7.99
I would use:
But how Can I scan a file that is divided with spaces? For example:
while (3 == fscanf(fp, "%[^;];%d;%lf\n", name, &qu, &amount))
Seinfeld 50 75
Carson 40 20
Leno 45 50
Letterman 20 95
I tried a couple of things, but I was unsuccessful, How Can I do this?
I'd try something like
and then trim the first string
First I would suggest you read the whole like using fgets, then attempt to parse it with sscanf.
If the converted result isn't 3, then the file is already tidied up for you (because you read the whole line with fgets).