By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,083 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,083 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Jun 17 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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.

--
Obnoxious User
Jun 17 '07 #2

P: n/a
On Jun 17, 10:34 pm, Obnoxious User <O...@127.0.0.1wrote:
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.

--
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

Jun 17 '07 #3

P: n/a
On Sun, 17 Jun 2007 06:08:14 -0700, Jess wrote:
On Jun 17, 10:34 pm, Obnoxious User <O...@127.0.0.1wrote:
>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.

--
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
Jun 17 '07 #4

P: n/a
Jess wrote:
On Jun 17, 10:34 pm, Obnoxious User <O...@127.0.0.1wrote:
>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.

--
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
Jun 17 '07 #5

P: n/a
On Jun 17, 11:18 pm, John Harrison <john_androni...@hotmail.com>
wrote:
Jess wrote:
On Jun 17, 10:34 pm, Obnoxious User <O...@127.0.0.1wrote:
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.
--
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
Thanks!
Jess

Jun 17 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.