C++.



         


C-, string. .   . C-, .. , , . , , , :

#include <iostream>

#include <string.h>

char inBuf[ 1024 ];

try

{

while ( cin >> inBuf ) {

char *str = new char[ strlen( inBuf ) + 1 ];

strcpy( str, inBuf );

// ... - str

delete [] str;

}

}

catch( ... ) { delete [] str; throw; }

string

:

#include <iostream>

#include <string.h>

string str;

while ( cin >> str )

// ... -

C- string. - :

Alice Emma has long flowing red hair. Her Daddy says

when the wind blows through her hair, it looks almost

alive, like a fiery bird in flight. A beautiful fiery

bird, he tells her, magical but untamed. "Daddy, shush,

there is no such creature," she tells him, at the same time

wanting him to tell her more. Shyly, she asks, "I mean,

Daddy, is there?"

alice_emma, . , , . C- :

#include <iostream.h>

#include <string.h>

int main()

{

const int bufSize = 24;

char buf[ bufSize ], largest[ bufSize ];

//

int curLen, max = -1, cnt = 0;

while ( cin >> buf )

{

curLen = strlen( buf );

++cnt;

// ?

if ( curLen > max ) {

max = curLen;

strcpy( largest, buf );

}

}

cout << " "

<< cnt << endl;

cout << " "

<< max << endl;

cout << " "

<< largest << endl;

<