1,105,232 Community Members

question about gdb, how to debug a program with input file

Member Avatar
shean1488
Junior Poster in Training
67 posts since Feb 2012
Reputation Points: -3 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi everybody,

I just want to know how to use gdb if I want to see the value of my variable, that I get from a file.
To make it clear I will give an example:
lets say I have a file 'str.txt'
and a program that counts the word "daniweb".
to just run this program I would type something like this:

$ program.c < str.txt > program

and it would give a result lets say 5
So my question is how can I debug my program with this file
I want to get something like this:

gcc -g program.c -o program
...
(gdb) s
(gdb) p count[2] = 3 // count is counting word daniweb
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: