C "Expected Expression" error with Xcode

40,956

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:

Sample invisible bad character

Which causes the "Expected Expression" error.

Share:
40,956
Magwich
Author by

Magwich

I am a hobbyist programmer who likes to write useful code for others or myself. After trying out several languages over the last 20 years, I now mostly use Java and Python 3, and I am quite happy with them.

Updated on February 07, 2020

Comments

  • Magwich
    Magwich about 4 years

    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?