0

I have a compiled program that takes strings as input using stdin five times (in a loop). Every time after taking input it does some work on it and gives an output. I want to debug it gdb and I have to give it input from a file.

I cannot give input from keyboard directly.
I want to give the same string every time the program asks for input.
I have tried run < input.txt
But it seems to me that the program takes input from this file only the first time and after that it only reads null for other 4 inputs.

So I want to know if there is a way to solve this problem. And am I right about the thing that input is read from file only the first time program asks for input and not read from the file rest of the times?

Wajahat
  • 1,593
  • 3
  • 20
  • 47
  • What is your version of `gdb` ? Because it can't work on the Cygwin `gdb`. See: [gdb input redirection using cygwin](http://stackoverflow.com/questions/9031554/gdb-input-redirection-using-cygwin) – perror Apr 24 '13 at 15:41
  • No I have (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04 – Wajahat Apr 25 '13 at 17:54

1 Answers1

1

The run < input.txt and set args < input.txt and then run should work for all reads from stdin. Maybe you are onto the bug in your program that you are trying to find.

Bryan Olivier
  • 5,207
  • 2
  • 16
  • 18
  • I used the set args command and then ran using ran < input.txt but I don't know, it did not work I think. – Wajahat Apr 25 '13 at 17:52