> In order to run this program, the following is done
> ./justify <quote
TBH, I would add a second option to justify, namely to open the file supplied as a command line argument.
As in
./justify quote
Code:
int main ( int argc, char *argv[] ) {
FILE *in = stdin; // by default
if ( argc > 1 ) {
in = fopen(argv[1],"r");
}
// now you read from stdin or a file
char buff[BUFSIZ];
while ( fgets( buff, BUFSIZ, in ) ) {
}
}
To do what you want, you would have to keep editing your quote file to intermix all the gdb commands with all the actual program input.
As soon as you hit a breakpoint, gdb is just going to try to interpret the rest of the input file as gdb commands, and that just isn't going to work.
It's fine to share stdin between the program and gdb in an interactive session, because you know at each keystroke whether you're talking to the program or gdb.