我的程序获取所有数据并询问您是否希望以 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);
}
}