Connecting Tech Pros Worldwide Help | Site Map

ofstream output

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 27th, 2006, 07:25 AM
bob@blah.com
Guest
 
Posts: n/a
Default ofstream output

Hi,

I'm working with an ofstream object and using it to print the contents
on an 100 * 100 matrix. i.e. lots of elements. the _matrix variable
below is defined as std::vector<std::string, std::string>

When I run the code below I see the TTK_LOG( our logging function) call
correctly outputting all the values in the matrix. However I never see
anything output to the ofstream. (there's other data put into the
ofstream object elsewhere and I correctly see that). However my matrix
data never makes it.... or at least of ofstream object has a problem
somewhere along the line.

void cvs_export_container::dump(std::ofstream& os)
{
unsigned int x =0;
while (x < _matrix.size() )
{

unsigned int y=0;
while (y < _matrix[x].size())
{
os << _matrix[x][y] << _separator;
TTK_LOG("streamed: " << _matrix[x][y] << _separator
);
++y;
}

os <<"\n";

++x;
}

os.flush();
os.close();


Can anybody suggest what I should look for to fix the problem?

thanks much and have a nice day.

Graham


  #2  
Old March 27th, 2006, 10:25 AM
bob@blah.com
Guest
 
Posts: n/a
Default Re: ofstream output

Forgeddit. I found it... off by 1 bug... just before the above code
executes. The most frequent source of bugs in software apparently, and
I just let it happen to me gRRR! : )

  #3  
Old March 27th, 2006, 01:45 PM
bonczz@gmail.com
Guest
 
Posts: n/a
Default Re: ofstream output

Hi[color=blue]
>the _matrix variable below is defined as std::vector<std::string, std::string>[/color]

in the vector the second template parameter shoud be leaved blank or
should be an Allocator (http://www.sgi.com/tech/stl/Vector.html)
IMHO there is no chance to declare a matrix this way.
Next time google before ask.

sorry if i was wrong

 

Bookmarks

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.