私は、メインスレッドで華氏を尋ねるための単純なC++プログラムを作成しています。そして、この値を別のスレッドのCelsiusに変換します。シンプルなスレッドの仕事をC++で
しかし、私は1つのエラーを取得し続けます。このエラーは次のようになります
visual studio 2008 \ projects \ cs1 \ cs1 \ cs1.cpp(16):エラーC2143: before '='
この問題は時々消えますが、その代わりに実行時例外が表示されます。 私はVisual studio 2008、Windows XPを使用しています。多くのC/C++コンパイラ、特にマイクロソフトのもの、遠いで
おかげ-Sunnyジェイン
#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;
}
中の#defineは別のスレッドで実行する複雑な十分な作業のようには思えないです。 –