I'm just following the rule of thumb that says you never use post increment or post decrement unless you have a valid reason to use the 'old' return value.
well... You could use _itoa and print (not printf!).
By doing something similar with file pointers and a 7+mb file, i sped up a loop from ~25s to ~10s. Considering my hd is slow as hell...
Remember that printf calls vsprintf, but print doesn't.
Ahem? He looped through int-only conversion... He only needed _itoa, not a %d/parameter... And even if he did just _itoa, printf will keep on checking for %'s.
staticchar buffer[1024*1024*4] ;
// implementation defined : this may or may not have an effect
// an implementation may choose to do nothing about the buffer
std::cout.rdbuf()->pubsetbuf( buffer, sizeof(buffer) ) ;
// this should speed it up
std::cout.sync_with_stdio(false) ;
for( int j=0; j<100000 ; ++j ) std::cout << j << ' ' ;
// C equivalent of the above:
// static char buffer[1024*1024*4] ;
// int j = 0 ;
// setvbuf( stdout, buffer, _IOFBF, sizeof(buffer) ) ;
// for( ; j<100000 ; ++j ) fprintf( stdout, "%d ", j ) ;