【发布时间】:2015-11-08 19:13:35
【问题描述】:
这段代码给了我错误:
#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 语句,它就可以工作。 不明白为什么。
【问题讨论】:
-
我真的很怀疑这与它有什么关系。错误消息(“无法打开文件...”)表明,当您尝试重新编译和链接时,应用程序可能仍在运行。
-
尝试重命名文件
c:\users\payman\documents\visual studio 2015\Projects\ConsoleApplication2\Debug\ConsoleApplication2.exe,然后再次尝试构建和运行。