Write a URL in a C++ program

3.3

Writing URLs in a C++ code doesn’t affect the program and the compiler will not throw any error.

// C++ program to demonstrate URL in code
#include <iostream>
using namespace std;

int main()
{
    http://www.geeksforgeeks.org/

    for (int i = 0; i < 5; i++)
    {
        cout << "This code is error free" << endl ;

        // Uncommenting below goto statement causes 
        // infinite loop
        // goto http;
    }

    return 0;
}

Output:

This code is error free
This code is error free
This code is error free
This code is error free
This code is error free

Explanation:

  1. Any identifier followed by a : becomes a (goto) labels in C.
  2. A single line comment begins with a // and so in http://www.geeksforgeeks.org/ and so it is a comment. And therefore:
    label- http:
    comment- www.geeksforgeeks.org/

This article is contributed by MAZHAR IMAM KHAN. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

GATE CS Corner    Company Wise Coding Practice

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.

Recommended Posts:



3.3 Average Difficulty : 3.3/5.0
Based on 10 vote(s)










Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.