user3597140
user3597140

Reputation: 41

(lldb) error code not working in Xcode with C++

Im just starting with C++ and I wanted to try running this test... When I try compiling the code it just gives an error saying (lldb):

#include <iostream>

using namespace std;

//---------My Function--------//`

int addNums(int x, int y){
    int answer = x + y;
    return answer;
}

int main(int argc, const char * argv[]){
    // insert code here...
    /*
    int num;
    cin >> num;
    cout << num;
    cout << "\n";

    char hm[] = "eef";
    cout << hm[2] << endl;
    */

    cout << addNums(1, 2);
    return 0;
}

Upvotes: 1

Views: 4870

Answers (1)

Jim Ingham
Jim Ingham

Reputation: 27110

If by "Build" you mean you clicked the Play button - the leftmost button in the toolbar - then this is going to build and run your code. The build probably went fine. You can check that the build went okay by switching to the Reports navigator (the one with the speech bubble icon) and click on the latest Build report... If you want to build without running, Cmd-B is what you want to do.

Anyway, if you asked to build & run, and the build went okay, Xcode will start your program in the debugger, which will switch to the Debugger UI. Since your program just prints something and exits, the Debugger should have just printed "3" in the Debugger Console and exited. Not sure why you are seeing an lldb prompt, that is not what I see.

You might try setting a breakpoint, and see what the debugger looks like when you hit the breakpoint.

Upvotes: 1

Related Questions