PDA

View Full Version : it doesn't get any more basic


Doom9
31st May 2005, 18:01
it's been ages since I've used C the last time (not my favorite language really.. no objects, pointers, ugh). Anyway, I need to parse a string in the format "integer, char, double"

int start;
double value;
char mode;
int e = sscanf(p, "%d,%c,%f", &start, &mode, &value);
int q = (int)(value * 100);

Suppose my double is 20... q ends up a huge number. I'm doing this blindly (no development environment) so all I have to go by is a C reference that tells me %f converts to a floating point number.

Doom9
31st May 2005, 18:23
hmm.. line 2 should read float valueshouldn't it? as %f is supposed to return a float *.

Doom9
31st May 2005, 18:52
alright, thanks to Chromix it's working now.. all that was needed was turning %f into %lf.