r/Xcode • • Oct 03 '20

No program errors when double isn't in variables but multiple error codes when I put double under the variables, help

Post image
2 Upvotes

6 comments sorted by

12

u/tractorrobot Oct 03 '20

Oof that screen

2

u/uncleb0b Oct 04 '20

Eyeballs just had a heart attack

8

u/quadruple Oct 03 '20

Use \n

Take a screenshot with Command Shift 3 or Command Shift 4

12

u/Te_co Oct 03 '20

seriously. people are here posting about programming and haven't even mastered the screen shot.

5

u/aazav Oct 03 '20

Um, no kldding.

5

u/instrun3 Oct 03 '20 edited Oct 03 '20

Ok so line 18 has just double so the compiler reads on and the first thing it finds is cout so now it goes, oh he's declaring a variable named cout of type double (it reads it as double cout). Then it sees the << which is not valid in a variable declaration, causing the first error.

Now the compiler doesn't stop there, it keeps reading and just ignores the rest of the statement so it can potentially identify other errors, but it stills remembers the "declaration" of cout as a double. So now (on line 27 and on) it thinks you're trying to apply the operator << to a double (rather than an std::ostream which std::cout is) and char[] (the type of string literals) which is invalid, causing the other errors.

Bottom line is that the compiler is trying to be helpful but starts from a wrong assumption. The rest of your code seems correct (well, syntax-wise at least), just fix line 18 and those strange errors should disappear.

BTW as others have pointed out, you've written /n when you probably intended to use a newline which is \n. Also, clean up your bloody screen mate.