为什么输入id后 程序就会卡死呢呢??
程序代码:
#include <stdio.h> #include <stdlib.h> #include <string.h> struct Account { unsigned int id; char citizen_id[19]; char name[32]; char address[128]; unsigned int balance; // 余额 Account* next; }; int intput(Account * p) { printf("ID:\n"); scanf("%d\n",p->id); printf("身份证:\n"); scanf("%s\n",p->citizen_id); if(sizeof(p->citizen_id)!=18) return 0; printf("name:\n"); scanf("%s\n",p->name); printf("adress:\n"); scanf("%s\n",p->address); printf("balance:\n"); scanf("%d\n",p->balance); return 0; } int main() { Account * a = (Account *)malloc(sizeof(Account)); if(intput(a)) { printf("输入成功\n!"); } else { printf("输入失败\n!"); } free(a); return 0; }
这是一个函数 ,为结构体赋值