Hi!

I'd like to know how to print something when the user ends the program (with ctrl-c for example).

An example is the "ping" command (in most linux versions), that gives the average ping when the user terminates it.

Thank you!

If u r actually working on a unix machine u can use the interrupt handling commands to do this job for you..

For example... you can program the Ctrl + C to act differently and end with the desired output on the screen.

If u r actually working on a unix machine u can use the interrupt handling commands to do this job for you..

For example... you can program the Ctrl + C to act differently and end with the desired output on the screen.

Thank you.
How can I do that? : ) Some kind of example would be great.
P.S. If it's hard, forget it... I'm quite new to C++ so I don't need more free complications :)

Well i don't remember the exact syntax but there is a system call called SIGINT in Unix to do the job for you.

Try looking up google with that and probably u might find the answer to ur problem.

Well i don't remember the exact syntax but there is a system call called SIGINT in Unix to do the job for you.

Try looking up google with that and probably u might find the answer to ur problem.

Thank you! I found what I needed!

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.