我正在创建一个简单的C++程序来询问用户在主线程中的华氏度,然后在另一个线程中将此值转换为Celsius.
但我继续得到一个错误.此错误保持不变
visual studio 2008\projects\cs1\cs1\cs1.cpp(16):错误C2143:语法错误:缺少';' 在'='之前
此问题有时会消失,但不会出现运行时异常.我正在使用Visual Studio 2008,Windows XP.
谢谢-Sunny Jain
#include "stdafx.h"
#include "stdafx.h"
#include "windows.h"
#include "stdlib.h"
#include "stdio.h"
#include "process.h"
#include "conio.h"
#include "iostream"
using namespace std;
bool flag= false;
void calculateTemperature_DegreeCelcius(void * Fahrenheit)
{
float far;
far=*((float*) Fahrenheit);
float celcius = (5.0/9.0)*(far - 32);
cout << "\nDegree Celcius :";
cout << celcius;
flag = true;
}
int _tmain(int argc, _TCHAR* argv[])
{
float temp_Fahrenheit;
while(true){
cout << "\nEnter Degree Fahrenheit value you want to convert to Degree Celcius\n";
cout << "Degree Fahrenheit :";
cin >> temp_Fahrenheit;
_beginthread(calculateTemperature_DegreeCelcius, 0, &temp_Fahrenheit);
while(true){
if(flag==false){
Sleep(200);
} else {
break;
}
}
char *command = (char *)NULL;
cout<< "\nDo you want to continue ? yes/no :";
cin>> command;
if (strcmp("yes",command)){
flag = false;
} else {
break;
}
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
far是WinDef.h中的#define
#define far
#define near
#if (!defined(_MAC)) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
#define pascal __stdcall
#else
#define pascal
#endif
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
866 次 |
| 最近记录: |