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);

}

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");

//...

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.

commented: Very interesting. Thanks for correcting me! +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.