我试图做一个简单的货币转换器使用C,但由于某种原因它不断给我的错误“错误必须是一个可修改的左值”。 我检查了我的代码,并没有发现任何问题。任何帮助?错误必须是一个可修改的左值
#include <stdio.h>
#include <stdlib.h>
void main(){
float jod_usd=1.41, usd_jod=0.71, jod_eur=1.26, eur_jod=0.8, currency;
char ic;
int f;
printf("Enter the number of your conversion option to continue...\n1- Convert from JOD\n2- Convert to JOD\n");
scanf("%d",&f);
printf("Enter the character of your second currency to continue...\nU - - USD\nE - - EUR\n");
scanf("%c",&ic);
printf("Enter your amount:\n");
scanf("%f",¤cy);
if(f==1&&(ic='U'||ic='u')){
printf("%.2f JOD - - %.2f USD\n",currency,(currency*jod_usd));
}
if(f==1&&(ic='E'||ic='e')){
printf("%.2f JOD - - %.2f EUR\n",currency,(currency*jod_eur));
}
if(f==0&&(ic='E'||ic='e')){
printf("%.2f EUR - - %.2f JOD\n",currency,(currency*eur_jod));
}
if(f==0&&(ic='U'||ic='u')){
printf("%.2f USD - - %.2f JOD\n",currency,(currency*usd_jod));
}
system("pause");
}
'(IC = 'U' || ic' .... hmmmm –
@SouravGhosh我不是,我只是写了一些资料,说清楚它是关于C编程的,对不起,如果听起来像这样,我会编辑它。 – Cor
正如Sourav Ghosh指出的,当使用'=='而不是'='时测试'ic'的值 – coyotte508