Reputation: 354
I'm given a char* arguments. Which is basically a input stream that consists of "hex-address new_val" and I need to read both values as int*. I'm using sscanf() and reading hex-address just fine, but I can't figure out the way to advance to read new_val.No matter what I tried - I get segfault. Here is what I have so far:
int set_new_val(Cmd *cp, char *arguments) {
int* addr;
int* val;
sscanf(arguments, "%x",&addr);
sscanf(arguments+?????, "%x",&val);
/*see if I read it correct*/
printf("adr = %x || val = %x\n",(unsigned int)*addr,(unsigned int)*val);
/*not finished*/
return 0;
}
Upvotes: 0
Views: 643
Reputation: 29352
int addr, val; // not int*
sscanf(arguments, "%x %x",&addr, &val);
printf("adr = %x || val = %x\n", addr, val);
Upvotes: 1