I am trying to compile this code example 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?
Sometimes when copying code from PDFs invisible unwanted characters are copied as well.
To fix this you can tell Xcode to show you all invisible characters by changing the editor properties from the top bar menu.
(top bar menu) → Editor → Show Invisibles
You will have to delete anything that looks strange strange, like a space being represented by an actual space (" ") or a little triangle ("^"). Keep in mind that in this mode spaces are represented with this symbol "⌴".
For example:
Which causes the "Expected Expression" error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With