gpt4 book ai didi

c - 是的,C 中没有字符串

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

<分区>

我搜索了论坛,似乎找不到适合我的特定问题的答案(我也试过谷歌)。我似乎在正确比较字符串("is"、"is"、“否”、“否”)时遇到了问题。我最初尝试了 if else,但我认为 while 循环更有效。有什么建议么?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

double far = 0;
double cel = 0;
double userValue = 0;
double endResult = 0;
int choice;
char *decision = "";


int main()
{
conversion();
return 0;
}

conversion() {
printf("Please enter a 1 for Celsius to Fahrenheit conversion OR\n a 2
for
Fahrenheit to Celsius conversion\n");

scanf("%d", &choice);

if(choice == 1) {
printf("Please enter a value for Celsius. Example 32 or 32.6\n");
scanf("%lf", &userValue);
endResult = (userValue * (9.0/5.0) + 32);
printf("%lf\n", endResult);
yesOrNo();
}

else

printf("Please enter a value for Fahrenheit. Example 212 or 212.6\n");
scanf("%lf", &userValue);
endResult = (userValue -32) * (5.0/9.0);
printf("%lf\n", endResult);
yesOrNo();

}


yesOrNo() {

printf("Do you want to continue? Enter Yes or No\n");
scanf(" %s", &decision);

while(decision == "Yes" || decision == "yes") {

conversion();

}

exit(0);

}

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