Cannot multiply because * creates a pointer

Code returns an error because it thinks I'm creating a pointer...

1
2
3
4
5
6
7
8
9
10
 float width;
    float solution;

    if(shape == "square"){
        cout << "Enter side length: " << endl;
        cin >> width;
        cout << endl;
        solution = width * width;
        cout << "Area = " << solution << endl;
    }


How can i simply multiply width * width?
What is the error message you are getting?
error: ISO C++ forbids comparison between pointer and integer [-fpermissive]|

It's creating a pointer when I just want to multiply.
The error is on line 4, not on line 8.
..and that error would be?
how did you declare shape?
void Area(int shape){
float width;
float solution;

if(shape == "square"){
cout << "Enter side length: " << endl;
cin >> width;
cout << endl;
solution = width * width;
cout << "Area = " << solution << endl;
}
}

Whole function, sorry.
void Area(int shape) what about string shape?

Int can't be "square" or so,it's string..
and there you have it

comparing two different data types.

int
string

choose one type for both my friend.
Topic archived. No new replies allowed.