?Linux?,sscanf
??????????????????????
???????sscanf
??????????:
#includeint main() { char input[] = "Hello, my name is John! I am 30 years old."; char name[20]; int age; // ??sscanf???????????? int result = sscanf(input, "Hello, my name is s! I am %d years old.", name, &age); if (result == 2) { printf("Name: %s\n", name); printf("Age: %d\n", age); } else { printf("Failed to parse the input string.\n"); } return 0; }
??????,????sscanf
??????input
?????????s
???????????19????(?????),%d
??????????????????????????(&age
),???????????????
????????:
Name: John Age: 30
???,sscanf
????????????????????????,??????2,????????????????