【发布时间】:2023-03-25 04:22:01
【问题描述】:
我写信是说我用 C++ 编写了一个程序,可以将摄氏温度转换为华氏温度(我知道,它已经完成,这是我在 c++ 中的第一个项目),一旦我完成并正在调试,它我输入后说[ERROR] 'SYSTEM' was not declared in this scope
SYSTEM ("PAUSE")
return 0;
}
, } 之前在代码中。我搜索了如何修复它,并转到谷歌引擎中的前 10 个链接,但没有一个有效。我可以使用一些帮助,我应该获得一个新的 IDE(编译器)吗?还是我只是不擅长C++?
我的代码是:
//
// Program to convert temperature from Celsius degree
// units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212 - 32)/100 + 32
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
// enter the temperature in Celsius
int celsius;
cout << “Enter the temperature in Celsius:”;
cin >> celsius;
// calculate conversion factor for Celsius
// to Fahrenheit
int factor;
factor = 212 - 32;
// use conversion factor to convert Celsius
// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32;
// output the results (followed by a NewLine)
cout << “Fahrenheit value is:”;
cout << fahrenheit << endl;
// wait until user is ready before terminating program
// to allow the user to see the program results
system(“PAUSE”);
return 0;
}
【问题讨论】:
-
如何编译包含此类引号的代码?我得到的第一个错误:prog.cpp:14:13: error:stray ‘\342’ in program。当您正确编辑代码时,我建议您
#include <stdlib.h>