1

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;
}
3
  • Please, add to your question detailed error information. Commented May 2, 2014 at 18:09
  • lldb is a debugging tool that xcode uses when executing compiled code. Your code looks fine, it seems to me that xcode can't find lldb. There is a way to turn off using lldb or switch it to gdb if I remember correctly. As Yuriy said, the exact error would be super helpful. Commented May 2, 2014 at 18:12
  • Thats the thing, all it says in the compiler is (lldb) do you know how I can change it to gdb if that will help Commented May 2, 2014 at 18:20

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.