gpt4 book ai didi

c - 为什么这段代码不能识别任何 if 语句?

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

<分区>

我的程序获取所有数据并询问您是否希望以 3 种不同的方式显示它。 CSV、TSV、XML。我添加了 2 个 if 语句,当试图让它们工作时,它会要求我选择我想要显示的设置,然后它会结束程序。这是为什么?

#include <stdio.h>
int main (int argc, char *argv[]) {
int phoneNumber;
char firstName[11];
char lastName[11];
char eMail[20];
int output;
int CSV;
int TSV;
int XML;

printf("Please enter the user's first name:");
scanf("%s", firstName);
printf("Please enter the user's last name:");
scanf("%s", lastName);
printf("Please enter the user's phone number:");
scanf("%i", &phoneNumber);
printf("Please enter the user's e-mail:");
scanf("%s", eMail);
printf("What output format would you like? (CSV,TSV/XML) ");
scanf("%d", &output);

if (output == 'CSV') {
printf("firstName,lastName,phoneNumber,eMail");
printf("%s,%s,%i,%s",firstName, lastName, phoneNumber, eMail);
}
else if (output == 'TSV') {
printf("firstName,\tlastName,\tphoneNumber,\teMail");
printf("%s,\t%s,\t%i,\t%s", firstName, lastName, phoneNumber, eMail);
}

}

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