0

hello guys...how can i use iostream.h in VS2008?? im using following code but it is no t working...

#include <windows.h>
#include <iostream.h>

HANDLE hEvent;

DWORD WINAPI SampleThread(LPVOID iValue)
{

int iFinish = 120;
for(int i=100;i<=iFinish;i++)
cout<<i<<endl;

SetEvent(hEvent);
return 0;

}

void main()
{

HANDLE hThread;
DWORD dwGenericThread;
hThread = CreateThread(NULL,0,SampleThread,NULL,0,&dwGenericThread);
if(hThread == NULL)
{

DWORD dwError = GetLastError();
cout<<"SCM:Error in Creating thread"<<dwError<<endl ;
return;

}

hEvent = CreateEvent(NULL,FALSE,FALSE,"Test");

cout<<"Started waiting for the thread to complete.."<<endl ;
WaitForSingleObject(hEvent,INFINITE);
cout<<"Thread Completed."<<endl ;

CloseHandle(hEvent);

}
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by thelamb
0

Is there a specific reason you're using iostream.h in the brackets? You typically omit the .h but you also forgot to declare the namespace you're working in. Lastly, the function that takes "Test" I believe takes a slightly bigger datatype than const char* try prefixing it with L--

//...
#include <iostream>

using namespace std;

//...

hEvent = CreateEvent(NULL,FALSE,FALSE,L"Test");

//...
1

Lastly, the function that takes "Test" I believe takes a slightly bigger datatype than const char* try prefixing it with L--

That depends if the OP is building with Unicode or multi-byte support.

Votes + Comments
Very interesting. Thanks for correcting me!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.