我试图通过在函数中使用scanf()
来获取输入字符串,但它一直在失败,我不知道为什么。
这是我的代码的一部分。
typedef struct node {
int id;
char * name;
char * address;
char * group;
struct node * next;
} data;
void showG(data * head) {
char * n = "";
int i = 0;
data * current = head;
scanf("%s", n);
printf("The group of %s is\n", n);
while (current != NULL) {
if (0 == strcmp(current->group, n)) {
printf("%d,%s,%s\n", current->id, current->name, current->address);
i = 1;
}
current = current->next;
}
if (0 == i) {
printf("no group found");
}
}