0

Behavior of sscanf

` #include <stdio.h> #include <string.h> int main() { char result[100] = "Philippe Dupont 30"; char x[50]; char y[50]; int z; sscanf(result, "%s%s%d", x, y, &z); printf("%s\n", x); printf("%s\n", y); printf("%d\n", z); I have a snippet printf("My first name is %s \n my last name is %d \n and I am %d years old\n", x, y, z); return 0; } ` And the output is Philippe Dupont 30 My first name is Philippe my last name is -1109962944 and I am 30 years old I don't understand why the output of y is an address in the long output

1st Nov 2019, 5:06 AM
‏‪kouty‬‏
‏‪kouty‬‏ - avatar
2 Respostas
+ 2
maybe you should try %s instead of %d
1st Nov 2019, 6:07 AM
Airree
Airree - avatar
0
Ahh. Stupid error
1st Nov 2019, 6:20 AM
‏‪kouty‬‏
‏‪kouty‬‏ - avatar