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.

commented: Nice explanation ! :) +1

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 :)

Member Avatar for stephen.id

lol thats some pretty basic bugs

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.