Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I just pasted a url to my code, and forgot to comment it, but I was surprised to see MSVC++ compiled it successfully. My code is like this,

void my_function()
{
    http://www.google.co.in/
}

How come this gets compiled by MSVC++?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
124 views
Welcome To Ask or Share your Answers For Others

1 Answer

Actually, http followed by a colon is treated as a label by C++, which you can use in goto statements (like goto http;), and the rest (i.e //www.google.co.in) is treated as single line comment. That's why it gets compiled.

See more,

 void your_function()
 {

        http://www.google.co.in/

        https://www.crazy_c++.com/

        ftp://c++_is_fun.edu

        //your code here
        int i = 10 ; //atleast one line of code is needed here to get compiled!
 }

By the way, I don't think the example you've written would get compiled. There should be at least one line of code after the url, only then it gets compiled on my PC. I'm using MSVC++ 2008.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...