Length of a stringstream

This is a discussion on Length of a stringstream within the C++ Programming forums, part of the General Programming Boards category; Howdy, Simple question, how can I get the size of all the data stored in a stringstream instance? Eg: Code: ...

  1. #1
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986

    Length of a stringstream

    Howdy,

    Simple question, how can I get the size of all the data stored in a stringstream instance? Eg:
    Code:
    stringstream Addresses;
    cout << Addresses.length() << endl;
    Where length() is the length of the data kept in the stringstream. I know length() isn't a member of stringstream, what other functions are there?

  2. #2
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    I think your best bet is to check the length of the string it holds:
    Code:
    stringstream Addresses;
    cout << Addresses.str().length() << endl;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 05:05 AM
  2. Strange string behavior
    By jcafaro10 in forum C Programming
    Replies: 2
    Last Post: 04-07-2009, 08:38 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Weird modification to string length
    By ChwanRen in forum C Programming
    Replies: 0
    Last Post: 08-17-2003, 11:45 AM
  5. length of string etc.
    By Peachy in forum C Programming
    Replies: 5
    Last Post: 09-27-2001, 01:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21