ubuntu系统编译hello world的c程序,出错。求帮助。
ubuntu系统编译hello world的c程序,报错。求帮助。。
#include <stdio.h>
int main()
{
printf(¨hello!¨);
return 0;
}
使用gcc编译报错:
mrguan@mrguan-K53SC:~$ gcc a.c
a.c: In function ‘main’:
a.c:4:2: error: stray ‘\302’ in program
printf(¨hello!¨);
^
a.c:4:2: error: stray ‘\250’ in program
a.c:4:11: error: ‘hello’ undeclared (first use in this function)
printf(¨hello!¨);
^
a.c:4:11: note: each undeclared identifier is reported only once for each function it appears in
a.c:4:16: error: expected ‘)’ before ‘!’ token
printf(¨hello!¨);
^
a.c:4:16: error: stray ‘\302’ in program
a.c:4:16: error: stray ‘\250’ in program
------解决思路----------------------
其实gcc的错误信息已经很明显了,就是那个hello
拷贝楼主的hello,看一下编码
$echo "(¨hello!¨)"
------解决思路----------------------
od -tx1
0000000 28 c2 a8 68 65 6c 6c 6f 21 c2 a8 29 0a
可见那个所谓的引号其实是一个unicode char "C2 A8"
其实是欧洲语言里面的分音符
U+00A8 ¨ c2 a8 DIAERESIS
源自(http://www.utf8-chartable.de/)
比如常见的naive很多时候可以看到naïve的写法
#include <stdio.h>
int main()
{
printf(¨hello!¨);
return 0;
}
使用gcc编译报错:
mrguan@mrguan-K53SC:~$ gcc a.c
a.c: In function ‘main’:
a.c:4:2: error: stray ‘\302’ in program
printf(¨hello!¨);
^
a.c:4:2: error: stray ‘\250’ in program
a.c:4:11: error: ‘hello’ undeclared (first use in this function)
printf(¨hello!¨);
^
a.c:4:11: note: each undeclared identifier is reported only once for each function it appears in
a.c:4:16: error: expected ‘)’ before ‘!’ token
printf(¨hello!¨);
^
a.c:4:16: error: stray ‘\302’ in program
a.c:4:16: error: stray ‘\250’ in program
------解决思路----------------------
其实gcc的错误信息已经很明显了,就是那个hello
拷贝楼主的hello,看一下编码
$echo "(¨hello!¨)"
------解决思路----------------------
od -tx1
0000000 28 c2 a8 68 65 6c 6c 6f 21 c2 a8 29 0a
可见那个所谓的引号其实是一个unicode char "C2 A8"
其实是欧洲语言里面的分音符
U+00A8 ¨ c2 a8 DIAERESIS
源自(http://www.utf8-chartable.de/)
比如常见的naive很多时候可以看到naïve的写法