typedef struct{
char *name;
bool exists_in_sys;
convert_table *data;
} unit;
float orig_quant;
unit *orig_unit = (unit*) malloc(sizeof(unit));
unit *new_unit = (unit*) malloc(sizeof(unit));
printf("Enter original quantity, original units, new units\n");
fscanf(stdin, "%f %s %s", &orig_quant, orig_unit->name, new_unit->name);
printf("Original unit: %s\n", orig_unit->name);
printf("New unit: %s\n",2) new_unit->name);
OK, so I would like to know:
1) Why the fscanf string assignment doesn't work... the last 2 printf's output
Original unit: (null)
New Unit: (null)
Isn't an fscanf string assignment supposed to work on a char pointer (which is what orig_unit->name is)?
2) Is there any way to manipulate the format characters after the format string? For example, if I could do something like
fscanf(stdin, "%s", strcpy(%s, other_string));
Thanks for any help or comments