Eleanor Eleanor - 1 month ago 12
C++ Question

Using function parameters and arguments in Xcode 8 with C++

I've only recently started learning to code (About 3 days ago, to be exact!) so I really have no idea what I'm doing, to the point that I'm having trouble researching answers to my questions because I don't really know the terminology for anything.

Anyway, I'm learning on learncpp.com, and I'm up to 1.4a – "A first look at function parameters and arguments".

I tried to run this piece of code:

#include <iostream>

void printValues(int x, int y)
{
std::cout << x << std::endl;
std::cout << y << std::endl;
}

int main()
{
printValues(6, 7);
return 0;
}


Apparently it's supposed to spit out:

6

7

in the console window.

However, when I run it, it just says (lldb) in the console window and in the variable window it says:

[A]x = int (6)

[A]y = int (7)

The program also doesn't seem to finish running as it should – it doesn't spit out the return number at the end and when I try to change it and rerun it it asks if I want to terminate the program that's already running.

If it's any help, it highlights this line in green:

std::cout << x << std::endl;


It might also be worth noting that the tutorials on the website use Visual Studios, so I assume there's a difference between two programs that's causing me to have a problem?

Sorry if there is an obvious way to find the answer to this question, I've done some Googling and I tried watching Youtube tutorials etc. but I can't seem to find anything addressing my issue. Maybe I'm not looking in the right place.

If anybody would be able to help me or even direct me to where I might find an answer that would be much appreciated.

Thank you!

Answer

Did you set a breakpoint on that line? Usually the debugger will stop on a line if there's an error, or the developer set a breakpoint on that line. If it's highlighted in green, that's a breakpoint. You should see a blue pointer to the left of the line, like this:

enter image description here

If you click on it, it will turn light blue and the breakpoint will be disabled. You can then either type "continue" at the prompt, or press the continue button (it's a right-pointing triangle with a rectangle to the left of it, sort of like the "Play/Pause" button on a music player).

To remove the breakpoint, grab the blue arrow and drag it to the left and then let go of it. It should disappear in a puff of smoke.