Help

Hey guys I need your help

they say this is infinite loop .. i just didn't understand why this is infinite

1
2
3
4
5
6
7
8
9
10
  #include <iostream.h>
void main()
{
 int count = 0;
while (count<2)
 {
 count <<"welcome to C++";
count++;
}
}
This is not infinite loop. It is invalid code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  #include <iostream.h>
#include <iostream>

void int main() //main() should retirn int
{
    int count = 0; 
    while (count<2) {
       count <<"welcome to C++"; //If it was a pointer you would do a left shift here
                                 // (essentually count = 0). But it's a string literal and incompatible type
                                 // so it is a compile error
        std::cout << "welcome to C++"; //Correct way
        count++;
    }
}
Last edited on
thank you bro
Topic archived. No new replies allowed.