shean1488 -3 Light Poster

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.