This programm counts words from input and then i have to print out the longest word, im i bit stuck on that, need to somehow loop trough all words and compare them, but thing is, that there can be whatever count of words and spaces, depends on input.
teikums=string, teikums in my language=sentence,thats just how i named my string, yes its up to user, how long the string will be, the size is not defined.you have to enter the sentence that will be stored in "teikums"
int words, len, position, nextposition;
cout<<"Write a sentence!\n";
for (int i=0; i<len; i++)
if (sentence[i]==' ') words++;
cout<<"There are this amount of words in a sentence: "<<words<<endl;
nextposition=sentence.find(" ", position+1);
this works,thanks, I did read the link, just im very much a beginner and dont really understand this function, as far as I understand is, istringstream copies my previous string teikums into new array and words are separated now, somehow i also have to make this display just the longest word