Programming with Passion

Make the best out of everything.

Tuesday, 14 February 2017

Write a URL in a C++ program


Write a URL in a C++ program


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.breakthecodenow.blogspot.in/
    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.breakthecodenow.blogspot.in and so it is a comment. And therefore:
    label- http:
    
    comment- www.breakthecodenow.blogspot.in/

No comments:

Post a Comment