How to fix (lldb) error in Xcode?
February 21, 2014 9:33 AM   Subscribe

I'm a new Xcode user (and a just learning C++). I'm trying to work with "if" and "else" statements. My program seems to run just fine for the "if else" and "else" statements, but my "if" statement at the beginning returns the result "(lldb)". More inside.

Here is the code I have written. I get correct responses when I test the program with rainy weekdays, sunny weekdays, and sunny weekends, but I get the result "(lldb)" if I enter Saturday and rainy or Sunday and rainy. Code:

#include
#include
using namespace std;
// This program will tell us what Mary will do based on the day of the week and the weather.

int main()
{
// Variables
string DayOfTheWeek;
string Weather;

// Ask for the day of the week
cout<>>DayOfTheWeek;

// Ask about the weather
cout<>>Weather;

if (Weather == "rainy" && (DayOfTheWeek == "Saturday" || DayOfTheWeek == "Sunday"))
cout<<"Mary will read a book"<<endl;

else if (Weather == "sunny" && (DayOfTheWeek == "Saturday" || DayOfTheWeek == "Sunday"))
cout<<"Mary will go outside"<<endl;

else if (Weather == "rainy" && (DayOfTheWeek == "Monday" || DayOfTheWeek == "Tuesday" || DayOfTheWeek == "Wednesday" || DayOfTheWeek == "Thursday" || DayOfTheWeek == "Friday"))
cout<<"Mary will go to class and take an umbrella"<<endl;

else cout<<"Mary will go to class"<<endl;

return 0;
}

Any advice?
posted by junipero to Computers & Internet (5 answers total)
 
Reformatting a litttle to catch that the MeFi HTML parser screwed up a bunch of your less thans and greater thans:
#include <iostream>
#include <string>

using namespace std;
// This program will tell us what Mary will do based on the day of the week and the weather.                           

int main()
{
// Variables                                                                                                           
    string DayOfTheWeek;
    string Weather;

// Ask for the day of the week                                                                                         
    cout << "Day of the week" << endl;
    cin >> DayOfTheWeek;

// Ask about the weather                                                                                               
    cout  << "How's the weather" << endl;
    cin >> Weather;

    if (Weather == "rainy" && (DayOfTheWeek == "Saturday" || DayOfTheWeek == "Sunday"))
        cout<<"Mary will read a book"<<endl;

    else if (Weather == "sunny" && (DayOfTheWeek == "Saturday" || DayOfTheWeek == "Sunday"))
        cout<<"Mary will go outside"<<endl;

    else if (Weather == "rainy" && (DayOfTheWeek == "Monday" || DayOfTheWeek == "Tuesday" || DayOfTheWeek == "Wednesday" || DayOfTheWeek == "Thursday" || DayOfTheWeek == "Friday"))
        cout<<"Mary will go to class and take an umbrella"<<endl;

    else cout<<"Mary will go to class"<<endl;

    return 0;
}
When I run this on Linux with "Sunday" and "rainy", I get:
Day of the week
Sunday
How's the weather
rainy
Mary will read a book
Mayby copy and paste my reformatted version back in and see if there's something weird typo that I accidentally corrected out? Also, maybe add a
cout <>
(careful attention to those single quote characters so that you can tell what's really in your variables, like leading and trailing spaces) to tell you if you're inputting what you think you're inputting. And remember that case is important?
posted by straw at 9:42 AM on February 21 [1 favorite]


Also, "(lldb)" is not an error message. It's the debugger's command line prompt.
posted by rlk at 9:44 AM on February 21 [1 favorite]


Thank you! straw, your code seems to be working so I think I can figure out my problem from here!
posted by junipero at 9:48 AM on February 21 [1 favorite]


You're welcome! And: doh. After that careful formatting up above, that mucked up line should be:
cout << "You entered '"  << DayOfTheWeek  <<  "' and '"  << Weather  <<  "'"  << endl;
Do you know how to use the command line tool "diff"? Doing a "diff yourversion.cpp strawsversion.cpp" can help you find errors. And once you start using diff, it's a short hop to using a version control system like git, which you really should start doing early...
posted by straw at 9:51 AM on February 21 [1 favorite]


Yes, lldb is the debugger. It's a console prompt; it's waiting for you to input a debugger command.

There nothing in the given code that would crash, which is one way to end up in the debugger. Another way is if you accidentally set a breakpoint. In Xcode you do this by clicking on the left hand margin of the code editor (something easy to do on mistake, I've done it before). If so you'd see a blue, right pointing arrow.

Right click on it to disable.
posted by sbutler at 3:44 PM on February 21


« Older If it's important I'm a young ...   |  Hello folks, this question is ... Newer »

You are not logged in, either login or create an account to post comments