Connecting Tech Pros Worldwide Help | Site Map

ofstream output

  #1  
Old March 27th, 2006, 08:25 AM
bob@blah.com
Guest
 
Posts: n/a
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, 11:25 AM
bob@blah.com
Guest
 
Posts: n/a

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, 02:45 PM
bonczz@gmail.com
Guest
 
Posts: n/a

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

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
compilation error using ofstream aaragon answers 15 September 28th, 2007 12:45 PM
ofstream - Save to File magix answers 3 October 1st, 2006 02:05 PM
output to a file Gaijinco answers 3 November 22nd, 2005 04:10 AM
ostream and ofstream overloading Chase Bradford answers 3 July 19th, 2005 09:21 PM