Use of exit() function

后端 未结 13 1433
离开以前
离开以前 2020-11-30 23:34

I want to know how and when can I use the exit() function like the program in my book:

#include

void main()
{
    int goals;
            


        
13条回答
  •  一个人的身影
    2020-11-30 23:48

    exit(int code); is declared in stdlib.h so you need an

    #include 
    

    Also:
    - You have no parameter for the exit(), it requires an int so provide one.
    - Burn this book, it uses goto which is (for everyone but linux kernel hackers) bad, very, very, VERY bad.

    Edit:
    Oh, and

    void main()
    

    is bad, too, it's:

    int main(int argc, char *argv[])
    

提交回复
热议问题