Connecting Tech Pros Worldwide Help | Site Map

what is "streamsize" and "width(n)"?

 
LinkBack Thread Tools Search this Thread
  #1  
Old June 17th, 2007, 12:45 PM
Jess
Guest
 
Posts: n/a
Default what is "streamsize" and "width(n)"?

Hello,

I read the specification of width(n) and it says this function allows
me to pad on the left to the stream's width, and this width is
"streamsize". What is streamsize exactly? Is it measured in the
number of chars or something?

Thanks,
Jess


  #2  
Old June 17th, 2007, 12:55 PM
Obnoxious User
Guest
 
Posts: n/a
Default Re: what is "streamsize" and "width(n)"?

On Sun, 17 Jun 2007 05:37:09 -0700, Jess wrote:
Quote:
Hello,
>
I read the specification of width(n) and it says this function allows
me to pad on the left to the stream's width, and this width is
"streamsize". What is streamsize exactly? Is it measured in the
number of chars or something?
>
It's a typedef for one of the signed basic integral types, representing
the number of characters transferred in an io operation, or the size
of io buffers.

--
Obnoxious User
  #3  
Old June 17th, 2007, 01:15 PM
Jess
Guest
 
Posts: n/a
Default Re: what is "streamsize" and "width(n)"?

On Jun 17, 10:34 pm, Obnoxious User <O...@127.0.0.1wrote:
Quote:
On Sun, 17 Jun 2007 05:37:09 -0700, Jess wrote:
Quote:
Hello,
>
Quote:
I read the specification of width(n) and it says this function allows
me to pad on the left to the stream's width, and this width is
"streamsize". What is streamsize exactly? Is it measured in the
number of chars or something?
>
It's a typedef for one of the signed basic integral types, representing
the number of characters transferred in an io operation, or the size
of io buffers.
>
--
Obnoxious User

I tried it on an example

cout.width(10);
cout << "hello" << endl;

Then I noticed there are only 5 characters padded on the left of
"hello". Why is it not 10?

Thanks,
Jess

  #4  
Old June 17th, 2007, 01:25 PM
Obnoxious User
Guest
 
Posts: n/a
Default Re: what is "streamsize" and "width(n)"?

On Sun, 17 Jun 2007 06:08:14 -0700, Jess wrote:
Quote:
On Jun 17, 10:34 pm, Obnoxious User <O...@127.0.0.1wrote:
Quote:
>On Sun, 17 Jun 2007 05:37:09 -0700, Jess wrote:
Quote:
Hello,
>>
Quote:
I read the specification of width(n) and it says this function allows
me to pad on the left to the stream's width, and this width is
"streamsize". What is streamsize exactly? Is it measured in the
number of chars or something?
>>
>It's a typedef for one of the signed basic integral types, representing
>the number of characters transferred in an io operation, or the size
>of io buffers.
>>
>--
> Obnoxious User
>
>
I tried it on an example
>
cout.width(10);
cout << "hello" << endl;
>
Then I noticed there are only 5 characters padded on the left of
"hello". Why is it not 10?
>
http://www.cplusplus.com/reference/i...ase/width.html

--
Obnoxious User
  #5  
Old June 17th, 2007, 01:25 PM
John Harrison
Guest
 
Posts: n/a
Default Re: what is "streamsize" and "width(n)"?

Jess wrote:
Quote:
On Jun 17, 10:34 pm, Obnoxious User <O...@127.0.0.1wrote:
Quote:
>On Sun, 17 Jun 2007 05:37:09 -0700, Jess wrote:
Quote:
>>Hello,
>>I read the specification of width(n) and it says this function allows
>>me to pad on the left to the stream's width, and this width is
>>"streamsize". What is streamsize exactly? Is it measured in the
>>number of chars or something?
>It's a typedef for one of the signed basic integral types, representing
>the number of characters transferred in an io operation, or the size
>of io buffers.
>>
>--
> Obnoxious User
>
>
I tried it on an example
>
cout.width(10);
cout << "hello" << endl;
>
Then I noticed there are only 5 characters padded on the left of
"hello". Why is it not 10?
>
Thanks,
Jess
>
Because "hello" is also five characters. width(10) means print the next
value in a 'field' of width 10, 5 spaces plus 5 for "hello" equals 10.

john
  #6  
Old June 17th, 2007, 01:35 PM
Jess
Guest
 
Posts: n/a
Default Re: what is "streamsize" and "width(n)"?

On Jun 17, 11:18 pm, John Harrison <john_androni...@hotmail.com>
wrote:
Quote:
Jess wrote:
Quote:
On Jun 17, 10:34 pm, Obnoxious User <O...@127.0.0.1wrote:
Quote:
On Sun, 17 Jun 2007 05:37:09 -0700, Jess wrote:
>Hello,
>I read the specification of width(n) and it says this function allows
>me to pad on the left to the stream's width, and this width is
>"streamsize". What is streamsize exactly? Is it measured in the
>number of chars or something?
It's a typedef for one of the signed basic integral types, representing
the number of characters transferred in an io operation, or the size
of io buffers.
>
Quote:
Quote:
--
Obnoxious User
>
Quote:
I tried it on an example
>
Quote:
cout.width(10);
cout << "hello" << endl;
>
Quote:
Then I noticed there are only 5 characters padded on the left of
"hello". Why is it not 10?
>
Quote:
Thanks,
Jess
>
Because "hello" is also five characters. width(10) means print the next
value in a 'field' of width 10, 5 spaces plus 5 for "hello" equals 10.
>
john
Thanks!
Jess

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.