Running gdb while passing in a file from standard input c
c
Solution
You can also do the redirection inside of gdb.
gdb a.out
# ...
(gdb) run < SampleData
EDIT based on update:
This text:
[Inferior 1 (process 19460) exited with code 03]
is a message from `gdb` itself. Inferior is the name given to a process being debugged by `gdb`. Here, there is only 1 (but there can be more than one). The exit code is the code your program terminated with. If your `main()` function completed, it's the value that it returned. If you called `exit()`, it's the value you passed. These values are often useful for passing information about if your program succeeded or failed back to the caller (such as a shell).
I'd suggest checking `EXIT_SUCCESS` and `EXIT_FAILURE` in C (which indicate a successful/failed run respectively). Many programs define additional exit codes to indicate specific errors.
Since the value here is `03`, which is an unusual exit code, I'd suggest maybe your `main()` is missing a return statement at the end?
Problem
So, when I run my program, I do ``` ./a.out < SampleData ``` How would I debug my program while still being able to pass in the SampleData file? Thanks Edited: I tried doing ``` gdb ./a.out run < SampleData ``` when I do it, it runs my program, outputs what it normally outputs, then leaves me with: "[Inferior 1 (process 19460) exited with code 03]" What?