cout在cin之前没有在visual studio社区C++中工作

cout not working before cin in visual studio community C++

本文关键字:社区 studio C++ 工作 visual cin cout      更新时间:2023-10-16

此代码给我错误:

#include "stdafx.h"
#include<iostream>
#include<string>
using namespace std;
int main()
 {
    string name;
    cout << "enter your name: "<<endl;
    cin >> name;
    cout << name << endl;
    return 0;
 }

错误为:错误LNK1104无法打开文件"c:\users\payman\documents\visual studio 2015\Projects\ConsoleApplication2\Debug\ConsoleApplication2.exe"

但如果我评论第一个cout声明,它是有效的。不明白为什么。

您的程序仍在运行,因此文件被锁定。这与代码完全无关。