Netbeans won't allow to type with std::getline()

Heiski

Estimable
May 11, 2014
2
0
4,510
0
I'm just getting into C++, and I have very little knowledge about it. I'm just learning basics, and std::getline seems not to work. Here's my code:
Code:
 std::string name;
 std::getline(std::cin, name);
 std::cout<<"Hi, "<<name<<'!';
When I run that code (I have included <iostream>and<string>) it runs with no errors, but I cant type to output window so getline could take that line. It works fine with std::cin but not with this one.

I use Netbeans as my IDE, and my C++ complier is minGW. I have tried to search answer from google but I have found nothing useful so far. Anyone having same problem? Oh, and my OS is Windows 7 64bit
 
This is your test compiled under Visual C++ Express, and it works as expected.
Code:
#include "stdafx.h"
#include <string>
#include <iostream>
#include <sstream>


int _tmain(int argc, _TCHAR* argv[])
{
    // greet the user
    std::string name;
    std::cout << "What is your name? ";
    std::getline(std::cin, name);
    std::cout << "Hello " << name << ", nice to meet you.\n";
}
 

ASK THE COMMUNITY