Another sscanf() question.
Code:
#include <stdio.h>
void valid_buy(int *, char *, float *);
int main()
{
int quantity = 0;
char description[80];
float price = 0;
valid_buy(&quantity, description, &price);
printf("Quantity: %d\nDescription: %s\nPrice: %f\n", quantity, description, price);
return 0;
}
void valid_buy(int *quantity, char *description, float *price)
{
char line[]= "1,blue car,2500.00";
/* I know I'm ignoring the return value of sscanf() but it's just for now */
sscanf(line, "%d, %49[^,], %f", &quantity, description, &price);
}
The string "blue car" gets assigned to variable description. However, int quantity and float price still have the value of 0, Why?