gpt4 book ai didi

C编程If语句变量变化

转载 作者:行者123 更新时间:2023-11-30 14:50:38 25 4
gpt4 key购买 nike

稍后在我的程序中,我想打印出用户在此处选择的目的地,我该怎么做?

void create(){
char name[200],from,to;
int age;


printf("Please enter your name :\n");
scanf("%s",&name);
printf("Please enter your age :\n");
scanf("%d",&age);
printf("Pick your current destination");
printf("\n1 for London\n2 for Manchester\n3 for Brighton\n4 for
Liverpool\n4 for reading\n5 for coventry\n");
scanf("%s",&from);

if(from == 1){
printf("Select your desired destination %s",&from);
from =("London");

最佳答案

看来你的意思是

scanf( " %c", &from );
^^^^^

//...

if( from == '1' ){
^^^

关于C编程If语句变量变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48928331/

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