You can use the peek member function to look at the next character in the stream without extracting it. For example:
if (cin.peek()!= c) return 0;