+2  A: 

I think you are missing the /* comment */ case.

Darin Dimitrov
I know, I'm planning on doing that after I make sure I've covered the cases for //
Geo
+11  A: 

The fun ones are formed by trigraphs and line continuations. My personal favorite is:

/??/
* this is a comment *??/
/
D.Shawley
Is this a multiline comment?
Geo
Does anyone even format their comments this way?
Aviral Dasgupta
I haven't seen that in a source file yet.
Geo
@aviraldg: I hope no one would ever do such a thing, but it is within the Standard so it is legal.
D.Shawley
@Geo: oops... yes... this is a multiline since it relies on line continuation (backslash). I've found accidental line continuation using `??/` at the end of a comment before - basically, `// a comment??/` will comment out the following line. Technically a multiline comment, but completely by accident.
D.Shawley
You have a space character before the first `*`, which ruins the whole thing :) That space character should be removed for your comment to work as intended
AndreyT
@Andrey: D'oh... I really wish MarkDown didn't require the extra level of indenting for code. It's too easy to do that. Thanks.
D.Shawley
+5  A: 

You don't seem to handle escaped quotes, like:

"Comment\"//also inside string"

versus

"Comment"//not inside string"
rsp
You're right! Thanks for the catch!
Geo
+6  A: 

I think you can't handle

  puts("Test \
    // not a comment");

and this is also likely to make problems:

  puts("'"); // this is a comment
Rüdiger Hanke
You're right! I'll have to rethink my approach.
Geo
+9  A: 
// Single line comments can\
actually be multi line.
Uqqeli
I like how the syntax highlighter failed on this one.
Kawa
@Kawa: that’s a limitation of the flawed approach to syntax highlighting that Stack Overflow is taking. :-( Even for much more conventional code the results are flaky.
Konrad Rudolph
+1  A: 

The handling of \ character at the end of the line is performed at the earlier translation phase (phase 2) than replacement of comments (phase 3). For this reason, a // comment can actually occupy more than one line in the original source file

// This \
whole thing \
is actually \
a single comment

P.S. Oh... I see this is already posted. OK, I'll keep it alive just for mentioning phases of translation :)

AndreyT
A: 

This is always a favourite:

// Why doesn't this run?????????????????????/
foo(bar);
me22
I think I have this handled.
Geo
i think you misread the question
Niek H.