Home

Jerry Coffin wrote:
>
>> string s;
>>
>> do
>> {
>> cin>>s;
>
> scanf("%s", s);


Yes, but this leaves room for overflow, while C++ new I/O facilities
together with the other high level facilities are more elegant, safe and
convenient (as far as I have read until now).


> does essentially the same thing, from the viewpoint of the stream. The
> one real difference is attributable to the string -- that it resizes
> itself as needed to accomodate the data being read.

Yes, which is nice, safe and convenient. If string gets more than it can
accommodate it throws a length_error exception. No way for overflow here.


>
>> or even this:
>>
>> char v[4];
>>
>> cin.width(4);
>>
>> cin>> v;
>
> scanf("%3s", s);
>
> or:
>
> fgets(buffer, 4, stdin);
>
> Don't get me wrong: I'm not arguing that iostreams lack advantages --
> only that the things you've cited don't (directly) show much advantage
> for them.


Well, the cin way looks more high level and convenient to me.

previous
next

Re: Local Functions...
Re: i need help:""<
Re: Python 3.0 migration plans?
Re: Python and Tkinter Programming--Expensive!
Module imports during object instantiation
Pajacyk
Kidprotect
Niechciane i Zapomniane
Fundacja Hobbit
Dzieci Niczyje