Hello,

I am trying to create a function that compares lower and upper bound IP addresses. If the lower bound IP address is greater than the upper bound IP address I would like the program to

1. display the error
2. terminate immediately

Problem is, when I use exit(0) to terminate immediately, the error message briefly appears on the console before exiting, hence the user never understands what their error is. Below is the code, kindly help.

if (lower_first > upper_first)
{
     printf("Lower-bound IP address > upper-bound IP address");
     exit(0);
}

Recommended Answers

All 3 Replies

Pause it.

if (lower_first > upper_first)
{
     printf("Lower-bound IP address > upper-bound IP address");
     cin.get();
     exit(0);
}

And you don't need to call a function to exit, just return 0;

Hello,


Actually, I had to add cin.get() twice for it to pause. It works now, thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.