Error C "Expected Expression" with Xcode

I am trying to compile this sample code from the book "Head First C" (page 50), and Xcode gives me the error "Parse Issue" "Expected Expression" and highlights the line "int longitude = -64;" in red.

#include <stdio.h> void go_south_east(int * lat, int * lon) { *lat = *lat - 1; *lon = *lon + 1; } int main() { int latitude = 32; int longitude = -64; go_south_east(&latitude,&longitude); printf("Avast! Now at: [%i, %i]\n", latitude, longitude); return 0; } 

I have no idea why. Can anyone help?

+8
c xcode compiler-errors
source share
1 answer

Sometimes when copying code from invisible PDF files, unwanted characters are copied.

To fix this, you can tell Xcode to show all invisible characters by changing the properties of the editor in the top menu bar.

 (top bar menu) → Editor → Show Invisibles 

You will need to delete anything that looks oddly strange, such as the space represented by the actual space (") or a small triangle (" ^ "). Keep in mind that in this mode, spaces are indicated by the symbol" ⌴ ".

For example:

Sample invisible bad character

What causes the "Expected Expression" error.

+32
source share

All Articles