bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

string and strstream and setw


From: Georg Ritter
Subject: string and strstream and setw
Date: Mon, 19 Feb 2001 13:16:32 +0100

Hi, 

wrong behavior: 
When trying to align strings (<string>) with ios::manipulaltors they
aren't:

#include <string>
#include <strtream>
#include <iomanip>
#include <iostream>

int main()
{
ostrstream a, b;
string str1("one");
string str2("two");

        a.setf( ios::right );
        b.setf( ios::right );

        a << setw(20) << str1 << setw(20) << str2 << endl;
        b << setw(20) << str1.c_str() << setw(20) << str2.c_str() << endl;

        cout << "This does not work" << endl;
        cout << a;

        cout << "This does: " << endl;
        cout << b;

        return 0;
}

On an HP the code produces:
This does not work
                 one                 two
This does: 
                 one                 two

On Linux with gcc version 2.95.2 19991024 (release):
This does not work
onetwo
This does: 
                 one                 two

Greetings, 

        Georg Ritter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]