简体   繁体   中英

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

this code gives me error:

#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;
 }

the error is: Error LNK1104 cannot open file 'c:\\users\\payman\\documents\\visual studio 2015\\Projects\\ConsoleApplication2\\Debug\\ConsoleApplication2.exe'

but if I comment out first cout statement it works. don't understand why.

Your program is still running and so the file is locked. This has absolutely nothing to do with the code.

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