We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,154 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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

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
1
Contributor
0
Replies
1
View
shean1488
Junior Poster in Training
68 posts since Feb 2012
Reputation Points: 18
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0545 seconds using 2.64MB