? Linux ?,sscanf
??????????????????
??????? sscanf
?????????:
#include#include int main() { char input[] = "Name: John, Age: 30, City: New York"; char name[20], city[20]; int age; // ?? Name ? City ?? int result = sscanf(input, "Name: [^,], Age: %d, City: s", name, &age, city); if (result == 3) { printf("Name: %s\n", name); printf("Age: %d\n", age); printf("City: %s\n", city); } else { printf("Error: Unable to extract fields.\n"); } return 0; }
??????,???? sscanf
??????????? Name
?Age
? City
?????,???? [^,]
???????? Name
??,????????????,???? s
???????? City
??,?????????
????????????:
Name: John Age: 30 City: New York
???,sscanf
?????????????????????????????,???????????????????,?????????????