0

Whenever I try to run GDB with speller.c and a text file/dictionary, GDB says "file format not recognized". Anyone have any idea what's going on?

3
  • What's the command that you're executing?
    – kzidane
    Aug 5 '14 at 0:10
  • gdb ./speller ~cs50/pset6/texts/austinpowers.txt
    – dottified
    Aug 5 '14 at 0:12
  • Make sure the executable file named speller (not speller.c) is already in the same directory where you currently are and don't pass any txt files as you run gdb, but rather, pass them as you run the program inside gdb using the r gdb command like that r ~cs50/pset6/texts/austinpowers.txt!
    – kzidane
    Aug 5 '14 at 0:24
3

gdb ./speller ~cs50/pset6/texts/austinpowers.txt

When you run GDB by passing two parameters like this, the second parameter is interpreted by GDB to mean a 'core dump' file, which is not what you want in this case.

To pass a command line argument to a program running in GDB, first load the program like this:

gdb ./speller

After the program is loaded into GDB, you can run the program like this:

run ~cs50/pset6/texts/austinpowers.txt

This will cause speller to execute passing ~cs50/pset6/texts/austinpowers.txt as the first command line argument, as if it had been run from the command line:

./speller ~cs50/pset6/texts/austinpowers.txt

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .