【发布时间】:2011-08-04 15:44:26
【问题描述】:
我正在处理这个问题: 我一直在创建链表(使用结构),我想从用户那里加载输入。 当我调试这段代码时,调试器停止在 scanf 行。
typedef struct Person{
char name[64];
int number;
} Person;
Person* record = malloc(sizeof(Person));
printf("Input name: \n");
scanf("%63s", record->name);
我知道 (*record).number == record->number 和 '&' 用于获取变量的地址,但如果我想使用 scanf,我不知道如何以最简单的方式解决我的问题用于加载输入。
提前致谢。
【问题讨论】:
-
没有调试器能用吗?
-
似乎工作..根据我。
-
不只是调试器在等待你的输入?
-
我在 Windows 7 中使用 Eclipse,当我运行程序时,它正在运行并且永不停止。 printf 不打印任何东西(因为代码肯定有错误)。
-
@John Bode:如下所述,Eclipse 环境肯定有一些意外行为,因为其他代码是正确的。
标签: c arrays struct char scanf