gpt4 book ai didi

c - 结构点问题

转载 作者:太空宇宙 更新时间:2023-11-04 04:17:49 26 4
gpt4 key购买 nike

我有一个结构变量“accounts”,在读取用户输入时,我遇到了这些类似的问题,我觉得每个问题的修复方法都是一样的。但是,我无法确定“帐户”或“.”之前的“表达式”是什么。关于问题是什么以及如何解决它有什么想法吗?

>main.c: In function âmainâ:
>main.c:143:18: error: expected expression before âaccountsâ
scanf("%s", &accounts.first[0]);
>main.c:146:18: error: expected expression before âaccountsâ
scanf("%s", &accounts.middle[0]);
^
>main.c:149:18: error: expected expression before âaccountsâ
scanf("%s", &accounts.last[0]);
^
>main.c:179:28: error: expected expression before â.â token
scanf("%d", &(accounts).accountBalance);
^
>main.c:180:13: error: expected identifier or â(â before â.â token
accounts.accountNum = tempAccNum;
^
>main.c:182:28: error: expected expression before âaccountsâ
accList[numAccounts] = accounts;

如果这有帮助的话,这里是我声明结构的地方:

typedef struct accounts
{
char first[20];
char middle[2];
char last[20];
int accountNum;
int accountBalance;
} accounts;

最佳答案

编译器显然不认为 accounts(accounts) 是表达式,这让我怀疑有一个类型叫做 accounts .如果是这种情况,您需要做的就是重命名类型或变量。

关于c - 结构点问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49887073/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com