簡體   English   中英

為什么我的.c編碼無法在GCC中編譯?

[英]Why my .c coding can't be compile in GCC?

我在c中有一個簡單的代碼:

#include <stdio.h>

main()
{
   printf(“Hello, world! /n”);
}

但我無法在GCC中編譯它。 我嘗試編譯它時的警告:

 1. gcc hello.c -o hello
 2. hello.c: In function 'main:
 3. hello.c:4:1: error: stray '\342' in program
 4. hello.c:4:1: error: stray '\200' in program
 5. hello.c:4:1: error: stray '\234' in program
 6. hello.c:4:11: error: 'Hello' undeclared (first use in this function)
 7. hello.c:4:11: note: each undeclared identifier is reported only once for each function
    it appears in
 8. hello.c:4:18: error: 'world' undeclared (first use in this function)
 9. hello.c:4:23: error: expected ')' before '!' token
 10. hello.c:4:23: error: stray '\342' in program
 11. hello.c:4:23: error: stray '\200' in program
 12. hello.c:4:23: error: stray '\235' in program

有人可以幫我嗎?

您會收到這些錯誤,因為您可能會從格式化的源中復制並粘貼該代碼。 不一樣" 。將它們改為,代碼將編譯。

您可能還應遵循主要定義為的慣例:

int main(void)

因此返回一個int

您可能還想將/ n更改為\\ n

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM