简体   繁体   中英

visual studio 2012 c++ no cout

I'm trying to learn c++ but a simple method like "cout" and "cin" does not exist this is my code:

#include "stdafx.h"
#include <iostream>


int _tmain(int argc, _TCHAR* argv[])
{
    cout>>"hello";
    return 0;
}

there is an error that says "error C2065: 'cout' : undeclared identifier"

and "IntelliSense: identifier "cout" is undefined"

cout is declared in the std namespace:

int _tmain(int argc, _TCHAR* argv[])
{
    std::cout << "hello";
    return 0;
}

You're also doing it wrong. Note how I have the angle brackets aboove.

Add #include <iostream> to stdafx.h . I was having trouble with that and it worked for me.

Adding using namespace std; may help, and also do cout << "hello" not >> .

cout is in std so you to have use using namespace std . And for cout operator is like << . >> this is for input ie cin .

#include "stdafx.h";
#include "iostream";
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    cout<<"hello";
    system("pause");
    return 0;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM