2

Hi, i'm trying to debug a program that I run with a command

cat 1.txt - | ./game

And I'm not sure how to start gdb with that command. I've seen answers to how to pipe to gdb, but it doesn't seem to work when I first want to pipe the file content but then use standard input (this is what the dash stands for). Can anyone help?

madasionka
  • 812
  • 2
  • 10
  • 29

1 Answers1

3

cat 1.txt - | ./game

This cat is pointless, you could just as easily do this: ./game < 1.txt.

Which can also be used to run the game under GDB:

gdb ./game
(gdb) run < 1.txt

See also this answer.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • 3
    The `cat` wasn't pointless. Without the dash the program looped printing the message and waiting for input, because the code looked something like this: `while (1) { printf("message"); if (scanf("%d", &var) > 0 && var >= 0 ) { break; } getchar();}` – madasionka Dec 13 '17 at 12:29