这是我的代码:
#include <cs50.h>
#include <stdio.h>
#include <strings.h>
int main(void)
{
int answer_compared;
do {
printf("What is your credit card number?\n");
long long credit_card = GetLongLong ();
printf("Is your credit card number is %lld?\n", credit_card);
printf("Please respond Yes or No.\n");
string answer = GetString ();
answer_compared = strncasecmp(answer, "y", 1);
} while (answer_compared != 0);
int long long cc = credit_card;
printf("Thank you.\n");
if (cc == 4){
printf("Visa\n");
}else if (cc == 34 || cc == 37){
printf("AMEX\n");
}else if (cc >= 51 && cc <= 55){
printf("MC\n");
}else printf("You did not enter an appropriate credit card.\n");
printf("I think this is what I need.\n");
}
我的错误是:
credit.c:17:32: error: use of undeclared identifier 'credit_card'
int long long cc = credit_card;
^
最初我将所有 cc 变量设置为 credit_card 但更改了它,因为它增加了 5 个错误,都是出于相同的原因。我试图找到讨论在 do-while 循环中创建变量的地方,但无济于事。
你能解释一下这里出了什么问题吗?