-1

这段代码给了我错误:

#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 语句,它就可以工作。不明白为什么。

4

1 回答 1

1

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

于 2015-11-08T19:59:21.440 回答