C“预期表达式”错误与Xcode

时间:2022-04-23 22:43:19

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.

我正试图从“Head First C”(第50页)这本书中编译这个代码示例,Xcode给出了错误的“Parse Issue”“Expected Expression”,并用红色突出显示了一行“int longitude = -64;”。

#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?

我不知道为什么。谁能帮忙吗?

1 个解决方案

#1


32  

Sometimes when copying code from PDFs invisible unwanted characters are copied as well.

有时当从PDFs复制代码时,不可见的不需要的字符也会被复制。

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

为了解决这个问题,您可以通过从顶部的bar菜单中更改编辑器属性来告诉Xcode显示所有看不见的字符。

(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:

例如:

C“预期表达式”错误与Xcode

Which causes the "Expected Expression" error.

这会导致“预期表达式”错误。

#1


32  

Sometimes when copying code from PDFs invisible unwanted characters are copied as well.

有时当从PDFs复制代码时,不可见的不需要的字符也会被复制。

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

为了解决这个问题,您可以通过从顶部的bar菜单中更改编辑器属性来告诉Xcode显示所有看不见的字符。

(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:

例如:

C“预期表达式”错误与Xcode

Which causes the "Expected Expression" error.

这会导致“预期表达式”错误。