Very raw with C. I’m writing a program that takes files as it’s arguments, but this is rather annoying for debugging (GDB). Rather than have to re-type the file list each time that I start off in GDB, I’d rather store the file names in an array and modify the program to read this array rather than the argv[] values.
I started out with
FILE*[5] inpFiles;
inpFiles[0] = &file1.txt;
but this is all wrong. I need to get some sort of reference to each of the input files so that I can get its memory address.
How can I do this? Thanks.
You can define a GDB command in
.gdbinitso you don’t need to modify your production code.For example, add the following lines in your
~/.gdbinitor.gdbinitin your working directory.Then, in GDB, just type the command
do, and GDB runsrun file1.txt file2.txt file3.txt file4.txt file5.txtfor you.