C 错误:输入结束时需要声明或语句
这个错误是从哪里冒出来的!!请帮忙!错误是需要在输入结束时声明或语句!在这种情况下应该怎么做??请帮忙C 错误:输入结束时需要声明或语句,c,C,这个错误是从哪里冒出来的!!请帮忙!错误是需要在输入结束时声明或语句!在这种情况下应该怎么做??请帮忙 #include<stdio.h> #include "jatin.h" int main() { int t1, t2; char sc1, sc2; while (1) { printf("Enter a temperature and a scale\n"); scanf("%d %c", &t1, &sc1); conv
#include<stdio.h>
#include "jatin.h"
int main() {
int t1, t2;
char sc1, sc2;
while (1) {
printf("Enter a temperature and a scale\n");
scanf("%d %c", &t1, &sc1);
convert_temp(t1, sc1, &t2, &sc2);
printf("%d %c = %d %c\n", t1, sc1, t2, sc2);
}
void convert_temp(int t1, char sc1, int *t2, char *sc2)
{
if (sc1 == 'F' || sc1 == 'f')
{
*t2 = (t1-32)/1.8;
}
else if (sc1 == 'C' || sc1 == 'c')
{
*t2 = (1.8*t1)+32;
}
else
{
printf("Enter valid temperature");
}
}
#包括
#包括“jatin.h”
int main(){
int t1,t2;
字符sc1,sc2;
而(1){
printf(“输入温度和刻度”);
scanf(“%d%c”、&t1和&sc1);
转换温度(t1、sc1、t2和sc2);
printf(“%d%c=%d%c\n”,t1,sc1,t2,sc2);
}
无效转换温度(int t1,char sc1,int*t2,char*sc2)
{
如果(sc1='F'| | sc1=='F')
{
*t2=(t1-32)/1.8;
}
else if(sc1=='C'| | sc1=='C')
{
*t2=(1.8*t1)+32;
}
其他的
{
printf(“输入有效温度”);
}
}
没有}
括号关闭main()
函数。我可以指出的一些问题包括:
main()
while (1) {
// ominous loop with no exit
// Be ready to cut the hard line.
}
jatin.h
main()函数中没有结束“}”括号。正确地格式化和缩进此混乱,您将看到。通常,当代码中的某个地方缺少
}
时,会发生此错误,这就是您的情况。