Question

everyone. I am learning C++ and running basic "Hello, world!" codes. I am using NetBeans with the minGW compiler.

The problem is every time I build or attempt to run the project, I get an error:

BUILD FAILED (exit value 2, total time: 38s)

"/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/Namen/Documents/NetBeansProjects/CppApplication_1'
"/C/msys/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/cppapplication_1.exe
make.exe[2]: Entering directory `/c/Users/Namen/Documents/NetBeansProjects/CppApplication_1'
mkdir -p build/Debug/MinGW-Windows
      0 [main] mkdir 5908 open_stackdumpfile: Dumping stack trace to mkdir.exe.stackdump
make.exe[2]: *** [build/Debug/MinGW-Windows/main.o] Error 5
make.exe[2]: Leaving directory `/c/Users/Namen/Documents/NetBeansProjects/CppApplication_1'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/Namen/Documents/NetBeansProjects/CppApplication_1'
make.exe": *** [.build-impl] Error 2


BUILD FAILED (exit value 2, total time: 38s)

What's odd is that I could keep clicking run, and sometimes the project will build and run successfully. Other times it will not...as if it's broken. It's actually not running at all now due to the error, however.

Apparently this is a common problem, yet I haven't been able to successfully use the solutions I've found.

I have the latest version of NetBeans as I've heard that this was a bug. v7.4 I believe I have the proper path in my environment variable: C:\MinGW\msys\1.0\bin\; C:\MinGW\bin

If it helps, this is my code:

#include <iostream>
#include <string>
using namespace std;

int main(){
    string Question = "What is your name?\n";
    cout << Question;
    string Answer;
    getline(cin, Answer + " : " + Answer);
    cout << Answer + "\n";
}
Was it helpful?

Solution

The code is given us, not even compile.

  • to time variable Answer in the function is wrong.

getline(cin, Answer + " : " + Answer);

c++

  • 1

    istream& getline (istream& is, string& str, char delim);

  • 2

    istream& getline (istream& is, string& str);

to have the input in one line, let the new line characters away.

...
string Question = "What is your name? : ";
cout << Question;
string Answer;
getline(cin, Answer);
cout << Answer + "\n";
return 0;
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top