Say I had a program running... like I was in the middle of entering 100 numbers into an array... is there a way I could program it so that one the user hits a key, say "cntrl-A", that the process will stop?

I was reading these lecture notes and the teacher said
The header file (blahblah.h) for a simple blahblah library is:

and then gave some code....am I suppose to type this in the program above the include# <blahblah.h> or below?


8 Years
Discussion Span
Last Post by vmanes

You can use ctrl-z (ctrl-d in *nix systems) to signal end of input - it works the same as running out of data when reading a file.

You might have something like

int arr[100] = { 0 };
int i = 0;
while( i < 100 && cin >> arr[i] )

That will stop the input when either you run out of space in the array or you press a ctrl-z

As to blah.h, if it's a local file (something in your project, not part of the compiler libraries) you include it using double quotes #include "my_header.h" blah.h is a separate file, with code that will be included into your program at compile time, just like the system libraries that you include.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.