Code:
sscanf(x, "%s %d %s", object.name, &object.price, object.category.b.name);
Where x is an string and object.name and object.category.b.name are parts of structures as is object.price. The strings work fine and if I replace %d with double it also works fine. But %d and %u seem to give either really large numbers or something completely different from what is supposed to be scanned.
Code:
typedef union{
char name[12];
int price;
category_t category;
} object_t;
There is another structure that connects category b to the above. changing int price to int* or unsigned int with corresponding %u in sscanf didn't help. Changing to double seems to produce the correct result however.
I've been working on this for several hours to no avail. Please help. I don't see how it could read doubles but not integers.