iostream with wincon?

I'm trying to make a windows aplication with a console.
Here's my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "windows.h"
#include <iostream>
#include <string>
using namespace std;

int __stdcall WinMain(HINSTANCE ,HINSTANCE, char*, int){
    AllocConsole();
    cout<<"Hello world ";
    string name;
    getline(cin, name);
    FreeConsole()
    return 0;
}


This gives me no output, but it works if I use windows functions.
Is there any way this could work with iostream?

Adding Console I/O to a Win32 GUI App
http://www.halcyon.com/~ast/dload/guicon.htm

The code on that page is horribly mis-formatted, but it is correct.

Enjoy!
Topic archived. No new replies allowed.