parsing string off a configuration using strtok in C
- by Jessica
in the configuration file i have entries similar to this one:
filepath = c:\Program Files\some value
Where the path can contain spaces and there are no quotes on that string. I tried parsing this with strtok like:
char *option;
char *value;
value = strtok(line, " =");
strcpy(option, value);
value = strtok(NULL, " =");
where line is the line I am reading from the file, option will contain the left side of the equal (filepath) and value will contain the right side (c:\program files\some value).
I know, it's poor coding, but I haven't found something better. sorry...
In any case, for those options where there's no space in the right side it works great, but in those containing spaces it only return the string until the 1st space: c:\Program.
Is there any other way to do this?
Code is appreciated.
Jessica