Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Linux by (9.5k points)

Below is the code, I have took from my book which uses exit() function: 

#include<stdio.h>

void main()

{

    int goals;

    printf("enter number of goals scored");

    scanf("%d",&goals);

    if(goals<=5)

        goto sos;

    else

    {

        printf("hehe");

        exit( );

    }

    sos:

    printf("to err is human");

}

It gives me an error “call to undefined function exit()” when I run it. 

Can anyone tell me how to exit the program and create an option to close the window? 

1 Answer

0 votes
by (19.7k points)

Whenever you use exit() function, add #include<stdlib.h>. Since the exit function accepts an integer, try to execute it as exit(0). 

If you want to learn more about Linuxthen go through this Linux tutorial by Intellipaat for more insights. 

Related questions

0 votes
1 answer
asked Apr 27, 2021 in Java by sheela_singh (9.5k points)
0 votes
1 answer
0 votes
1 answer
asked Feb 17, 2021 in Linux by rahulnayar01123 (6.1k points)

Browse Categories

...