2013-10-14 39 views
0

我正在学习C++,下面的示例trows“`输入'未声明(首次使用此函数)”。 我一直在阅读本网站的一些问题,它似乎与不声明函数有关。但我无法让它工作。任何帮助将不胜感激。错误:cout C++ undeclared

// 
// 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; 
} 
+5

你是在Microsoft Word上输入的吗? – 0x499602D2

+0

不,在DEV C++ IDE中,实际上我没有输入它。我从C++ For Dummy第5版中复制了这个例子。 – sms

回答

2

变化

cout << “Enter the temperature in Celsius:”; 

cout << "Enter the temperature in Celsius:"; 

“”""是不同的。

+0

谢谢,它工作。 – sms

+0

@sms:不客气:) – LihO

3

请使用简单的文本编辑器或IDE。你的报价不正确。

cout << “Enter the temperature in Celsius:”; 

应改为

cout << "Enter the temperature in Celsius:"; 

错误被抛出,因为引号应该像"

+0

感谢您的提示,我正在使用dev C++ IDE。 – sms