2
votes

I am trying to debug a C program which has scanf statements ,using Mingw gdb. I followed this post to compile the program and start the debugger using below commands

gcc -g -o sample sample.c 
gdb sample.exe            

and created the break point at main using break main. As my program needs an integer and string as input through scanf, I followed this post and created a file named input , with the contents

1
"InputString"

and run the program using debugger using

run < input

gdb doesn't seem to start the program and gives the following message

Starting program: F:\spoj\sample.exe < input
Don't know how to run.  Try "help target".

Please help me understand where I am going wrong.

1

1 Answers

3
votes

I use the following format to provide command line args to a program being run under gdb:

<shell> gdb a.out
gdb> set args "what ever you would provide on the command line"
gdb> run