Using this structure:
typedef struct sProduct{
int code;
char description[40];
int price;
};
I want to read a txt file with this format:
1,Vino Malbec,12
where the format is: code,description,price
. But I'm having problems to read the description when it has a space.
I tried this:
fscanf(file,"%d,%[^\n],%d\n",&p.code,&p.description,&p.price);
The code is being saved ok, but then in description is being saved Vino Malbec,12
, when I only want to save Vino Malbec
because 12
is the price.
Any help? Thanks!