我正在尝试将字符串分成几部分,但是这样做不正确。这是我的代码。
int main(void){
char point[2][2];
char *try="Distance P1 P2 // Prints the distance between P1 and P2.";
sscanf(try,"Distance %s %s",point[0], point[1]);
printf("point[0]:%s point[1]: %s\n",point[0],point[1] );
}
期待此
point[0]:P1 point[1]:P2
输出
point[0]:P1P2 point[1]: P2
#include <stdio.h>
int main(void){
char point[2][3];
char *try="Distance P1 P2 " ; // Prints the distance between P1 and P2;
sscanf(try,"Distance %s %s",point[0], point[1]);
printf("point[0]:%s point[1]: %s\n",point[0],point[1] );
return 0;
}