LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-06-2017, 07:20 AM   #1
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro
Posts: 6,440

Rep: Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287
I could use some detailed help on how to use dgb or its ddd.


I am writing a c++ program, using vector <char> reading in files, then storing the paths into it. It reads some directories just fine. But as soon as I created new files, then tried reading them into it, it fails.

When looped through again it just prints out empty new lines to the terminal with no information in it. if I run it again on a different dir with files that have been on my system for who knows how long then it works with them.

so I'd really like to figure out how to use this debugger to see what is really going on. ddd: I've got as far as starting the program, setting args and running it, it shows main .. but how to get past that file and into the file where it is being called to fill the vector and look at what is going on?
 
Old 10-06-2017, 07:29 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,129

Rep: Reputation: 3324Reputation: 3324Reputation: 3324Reputation: 3324Reputation: 3324Reputation: 3324Reputation: 3324Reputation: 3324Reputation: 3324Reputation: 3324Reputation: 3324
you need to compile and link everything with -g
 
Old 10-06-2017, 09:31 AM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: Slackware
Posts: 8,289

Rep: Reputation: 3366Reputation: 3366Reputation: 3366Reputation: 3366Reputation: 3366Reputation: 3366Reputation: 3366Reputation: 3366Reputation: 3366Reputation: 3366Reputation: 3366
Quote:
I am writing a c++ program, using vector <char> reading in files, then storing the paths into it.
Why are you not using strings?
 
Old 10-06-2017, 06:17 PM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro
Posts: 6,440

Original Poster
Rep: Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287
Quote:
Originally Posted by dugan View Post
Why are you not using strings?
some dweb told me to use char for reading in files, so I changed it to char*, then I changed it back to string, and do a conversion on it for the reason it needs a char * to read.
Code:
else if (S_ISREG(st.st_mode))
{ 
//	std::cout << "files "<< path<<std::endl;

	std::stringstream newStringPath;
	newStringPath << path;
	std::string myStringPath = newStringPath.str();

 	opts.dfile.push_back( myStringPath ); 
	opts.g++;
}
then when I need it to be a char *
Code:
std::string newFilename = walk_down(); // returns one element in the vector<string>
const char* filename = newFilename.c_str();
std::cout << " filename "<<filename<<std::endl;
img.image = imlib_load_image(filename);
Now I am NOT getting any garbage in the input, and that part of it is now working.

Last edited by BW-userx; 10-06-2017 at 06:52 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sed command to replace ddd.mm.ss.s with ddd:mm:ss.s? johnpaulodonnell Programming 4 06-08-2007 06:57 AM
ddd- help me out mmk622 Linux - Software 2 01-17-2006 09:29 PM
Ddd Zarnce Slackware 1 07-05-2003 10:02 PM
ddd Tommi Linux - Hardware 0 07-04-2003 12:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration