I need to read the standard input into a couple strings. Then determine
whether or not the same word is used IN SUCCESSION (ex. this cat cat is
really mean.).

Then count and print the word and how many times it was used. So using
the above example, it would print out the words that were used in
succession and how many times they were used. For example, the word cat
was used 2 times inthe above example.

I'm pretty much stuck on what sort of test to run to compare two or
more unknown words for sameness....

I need to read the standard input into a couple strings. Then determine whether or not the same word is used IN SUCCESSION (ex. this cat cat is really mean.).

Then count and print the word and how many times it was used. So using the above example, it would print out the words that were used in succession and how many times they were used. For example, the word cat was used 2 times inthe above example.

I'm pretty much stuck on what sort of test to run to compare two or more unknown words for sameness....

we aren't very far in the class past strings and vectors...

thanks for any help.

Try using std::string. If it doesn't work, show us what you have so
far, and we can give you some pointers. We're not going to do your
homework for you, however.

With the code you supplied, the program would just keep reading strings
until the state of cin goes bad, which only happens when it reaches end
of file (which wouldn't happen unless the user dumped a file to your
program, e.g., from the command line "myprog < file.txt") or when there
is an error on the device (which probably won't happen in your
environment). In short, it would never end (though at some point you'd
run out of memory).

As for the parsing of s1, you might use an istringstream (include
<sstream>), but I'm not sure if your professor wants you to do that.
Something like:

<tm****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

I'm a newb in a c++ class...

I need to read the standard input into a couple strings. Then determine whether or not the same word is used IN SUCCESSION (ex. this cat cat is really mean.).

Then count and print the word and how many times it was used. So using the above example, it would print out the words that were used in succession and how many times they were used. For example, the word cat was used 2 times inthe above example.

I'm pretty much stuck on what sort of test to run to compare two or more unknown words for sameness....

we aren't very far in the class past strings and vectors...

thanks for any help.

Consider this. Put each word in a vector, so you have a vector of
std::string, each string containing a word. Then iterate through the vector
checking if this current word is equal to the one before it if it is
increment a counter.

Jim: that's sort of the logic I was expecting; ie, it looks like the
sort of thing we have been doing in class.

Thanks for the help everyone. It's always amazing/confusing to me to
see how many different ways things can be done in programming. I guess
I always thought things were way more "rigid" when it comes to writing
this stuff.

Mlimber: This is one of the things that annoys me about our text: it
never tells you the whole story. It tells you to do things one way,
then 3 chapters later, you find it out that it is wrong to do it that
way.

so... on the subject of infinite loop. I have been trying to look up
what sort of command you use to "break out of" waiting for user input.

when I am using the linux system at school and I run my compiled
programs, the teacher told us to just hit ctrl-d after entering input
from the keyboard. After I do that, the next part of the code runs.

I can't figure out how to make the same thing happen when I run my
progs from the command prompt on my windows system.

Mlimber: This is one of the things that annoys me about our text: it never tells you the whole story. It tells you to do things one way, then 3 chapters later, you find it out that it is wrong to do it that way.

so... on the subject of infinite loop. I have been trying to look up what sort of command you use to "break out of" waiting for user input.

when I am using the linux system at school and I run my compiled programs, the teacher told us to just hit ctrl-d after entering input from the keyboard. After I do that, the next part of the code runs.

I can't figure out how to make the same thing happen when I run my progs from the command prompt on my windows system.

Jim: that's sort of the logic I was expecting; ie, it looks like the sort of thing we have been doing in class.
Note - when posting in comp.lang.c++ , please quote relevant pieces
of what you're replying to. Other people use different reader
software that might not show the older messages in the thread.
Thanks for the help everyone. It's always amazing/confusing to me to see how many different ways things can be done in programming. I guess I always thought things were way more "rigid" when it comes to writing this stuff.
From what you've said, there is no need to use a vector. The

only thing your code has to remember is the most recent string
read. Then all you have to do is read a new string, compare it
to the previous one (using == ), increment a counter if it is
equal, and then store the new string as the most-recent-string.
Wash, rinse, repeat.

while (cin >> s1)
You may need to define what a word is better than that. A string
doesn't necessarily correspond to a word. The standard input
stream is going to say, for example, that "cat" and "cat," (note
the comma) are different words.

If you'll only accept lists of words with no punctuation allowed,
i.e., won't handle real prose, then you should document that.

In addition, will "cat" and "Cat" be considered the same word?

I suggest documenting that you accept just a plain list of words,
and that you internally translate every character to lower case.
That is, unless the assignment rules that out.
v.push_back(s1);

So, do I want to do comparisons to find duplicates at the while/cin stage?

if so, i'm not sure how to keep track of them... can I tack on statements between the "while cin" and the "v.pushback" part?

grrr. I dont even know the right questions to ask.

You should get your professor to tell you what the output should
be for text like:

cat cat dog cat cat

Is it

1) "cat": 2, "cat": 2

or

2) "cat": 4

If 1 is the answer, then you don't need a vector at all.

If 2 is the answer, then you can use a vector, but using a map
would be less complex.