Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualCornstalks

Posted 13 January 2013 - 11:24 AM

Michaels-MacBook-Pro:~ mjbshaw$ cat t.cpp
#include <iostream>
#include <sstream>
 
int main()
{
    std::stringstream ss;
    for (int i = 0; i < 20000; ++i)
        ss << i << '\n';
 
    std::string str = ss.str();
 
    std::cout << "There are " << str.size() << " characters in ss and str\n";
    std::cout << "The contents of ss and str are:\n" << str;
}
Michaels-MacBook-Pro:~ mjbshaw$ g++ t.cpp && ./a.out 
There are 108890 characters in ss and str
The contents of ss and str are:
0
1
2
3
4
[...] (I'm not going to post all 20,000 numbers)
 
Seems to work just fine for me... I got 108,890 characters in ss and str...

#1Cornstalks

Posted 13 January 2013 - 11:23 AM

 
</p><div>$ cat t.cpp</div>
<div>#include <iostream></div>
<div>#include <sstream></div>
<div> </div>
<div>int main()</div>
<div>{</div>
<div>    std::stringstream ss;</div>
<div>    for (int i = 0; i < 20000; ++i)</div>
<div>        ss << i << '\n';</div>
<div> </div>
<div>    std::string str = ss.str();</div>
<div> </div>
<div>    std::cout << "There are " << str.size() << " characters in ss and str\n";</div>
<div>    std::cout << "The contents of ss and str are:\n" << str;</div>
<div>}</div>
<div>$ g++ t.cpp && ./a.out </div>
<div>There are 108890 characters in ss and str</div>
<div>The contents of ss and str are:</div>
<div>0</div>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>[...] (I'm not going to post all 20,000 numbers)</div>
<div>
 
Seems to work just fine for me... I got 108,890 characters in ss and str...

PARTNERS