从 C 中的结构中打印字符串有问题...
typedef struct box{
char *REF_OR_SYS; int num, x, y, w, h, o;
}BOX;
sscanf(str, "%s %d %d %d %d %d %d", &label, &refNum, &x, &y, &w, &h, &o);
BOX detect = {label, refNum, x, y, w, h, o};
printf("\nLABEL IS %s\n", detect.REF_OR_SYS); //Prints out the String correctly
//(Either the word REF or SYS)
return detect;
当这个结构被传递给另一个结构时,除了字符串之外的所有内容都会正确显示。
void printBox(BOX detect){
printf("Type: %s Ref: %d X: %d Y: %d W: %d H: %d O:%d\n",
detect.REF_OR_SYS, detect.num, detect.x,
detect.y, detect.w, detect.h, detect.o);
}
我错过了一些简单的东西吗?REF_OR_SYS 始终打印为 ??_?