visual studio 2012 c++ no cout

visual studio 2012 c++ no cout

本文关键字:no cout c++ 2012 studio visual      更新时间:2023-10-16

我正在尝试学习c++,但不存在像"cout"answers"cin"这样的简单方法这是我的代码:

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

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

有一个错误,上面写着"错误C2065:‘cout’:未声明的标识符"

和"IntelliSense:标识符"cout"未定义"

coutstd命名空间中声明:

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

你也做错了。注意上面的尖括号。

#include <iostream>添加到stdafx.h。我遇到了麻烦,这对我很有效。

添加using namespace std;可能会有所帮助,也可以执行cout << "hello"而不是>>

coutstd中,因此您必须使用using namespace std。而对于cout,运算符与<<类似。>>这是用于输入的,即cin

#include "stdafx.h";
#include "iostream";
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    cout<<"hello";
    system("pause");
    return 0;
}