gpt4 book ai didi

c - 想为银行制作 c 程序应用程序

转载 作者:太空宇宙 更新时间:2023-11-04 07:07:16 24 4
gpt4 key购买 nike

我已经制作了结构,但我卡在了最后一点,我必须执行 if/else 编码。这是我的第一个程序,使用了网络上的一些教程。

代码如下:

#include<stdio.h>
#include<conio.h>

int main()
{
char fName;
char mName;
char lName;
int dob;
int branch;
int brcode;
char * pbprint;

printf("\tWELCOME TO BANK OF KANPUR :: ONE HAND ROLE TO YOUR SUCCESS");

printf("\n\n\n Customer Detail Form");
printf("\n ---------------------");
printf("\n\n\tCustomer Entity ");
printf("\n ");

printf("\n\n\n Customer's First Name : ");
scanf("%s", &fName);

printf("\n Customer's Middle Name : ");
scanf("%s", &mName);

printf("\n Customer's Last Name : ");
scanf("%s", &lName);

printf("\n\n\tDate of Birth ");
printf("\n ");

printf("\n\n\nDate[DD] : ");
scanf("%d", &dob);

printf("\nMonth[MM] : ");
scanf("%d", &dob);

printf("\nYear[YYYY] : ");
scanf("%d", &dob);

printf("\n\n\tBranch Details ");
printf("\n ");

printf("\n\n\nBranch Code : ");
scanf("%d", &brcode);

printf("\n\n\tPrinter ");
printf("\n ");

printf("\n\n\nWould You Like Us To Print Your Passbook [Y/N] : ");
scanf("%s", &pbprint);


// please help how to make if else statement here
// how to make the condition when if I enter yes it should show your
// printing is done else your printing is not done.
getchar();

return 0;
}

最佳答案

您正在从控制台读取一个字符串。如果我理解,一个简单的方法是只检查字符串中的第一个字符。你可以这样做:

if ( (pbprint[0] == 'Y') || (pbprint[0] == 'y') )
{
printf("your printing is done");
}
else
{
printf("your printing is not done");
}

用户通常非常有创意,因此您可以选择您的输入界面应该有多智能和多才多艺。

关于c - 想为银行制作 c 程序应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31614814/

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