一個很笨,有關gcc的問題 - Linux

Table of Contents


//---------以下是程式碼:---------------------

#include <stdio.h>

int main()
{
printf("Hello World\n");
exit(0);
}


//--------------------------------------------
我下了這個指令
$gcc -c hello.c

卻產生錯誤訊息
hello.c: 在函式 「main」 中:
hello.c:6: 警告: 隱含宣告與內建函式 「exit」 不相容

請問該怎麼解決呢?

--

All Comments

Elma avatarElma2008-07-06
include stdlib
Carolina Franco avatarCarolina Franco2008-07-10
或是改用return別用exit
Christine avatarChristine2008-07-14
因為exit()是宣告在stdlib.h當中的
Una avatarUna2008-07-15
謝謝,那請問exit(0),和return 0的意思是一樣的嗎?
Joseph avatarJoseph2008-07-15
在這種情況下,exit(0) 和 return 0 意思是一樣的