Hi all,
what is the bug in the following code:

#include <iostream> 
#include <string>
int main()
{
string str = "Hello World!"
cout << str << endl;
cout << float x = 5.0f * str << endl;
int 65Num = 65;
cout << "65Num = " << 65Num << endl;
}

Hi all,
what is the bug in the following code:

#include <iostream> 
#include <string>
int main()
{
string str = "Hello World!"
cout << str << endl;
cout << float x = 5.0f * str << endl;
int 65Num = 65;
cout << "65Num = " << 65Num << endl;
}

There are a lot of "bugs" in your code.
Frist, you miss the using namespace std; line before the main() function, so the compiler might not recognize cout and string .
You also missed a semicolon after "Hello World!" .
Another thing is that you can't declare variables inside cout , so you should take float x = 5.0f * str outside cout . The multiplication operation of a float type and string type is not even declared, so float x = 5.0f * str has no meaning. The variable 65Num has an "illegal" name - variables' names cannot begin with a digit.

Comments
Nice explanation ! :)

What a crap this code is ?
60% of your code is full of bugs ...

Read your textbook first !

By the way, in future post using code tags ...

sorry, this not my code, it was an exercise want me to correct bugs, thanks "unbeatable0" for helping.

What a crap this code is ?
60% of your code is full of bugs ...

Read your textbook first !

By the way, in future post using code tags ...

Looks a lot like my code too :)

lol thats some pretty basic bugs

This article has been dead for over six months. Start a new discussion instead.