c++ - error : binary '>>' : no operator found which takes a right-hand operand of type 'const char [1] -
this question has answer here:
mine simple c++ program calculate area of circle, error.can me? i'm new c++. here program:
#include "stdafx.h" #include <iostream> using namespace std; int main() { int area; float r; area = 3.14 * r * r; cin >> "enter radius" >> r; cout << "area of circle is:" << area; return 0; }
you can't read in literal "enter radius"; compiler telling you: it's attempting write first element of literal const char[1] type.
you need display message user via cout, when you're outputting area. read in radius using
cin >> r; you ought not evaluate area until r known.
(by way, definition of pi woeful float type: tend use atan(1)*4 pi; c++ standard library not define you.)
Comments
Post a Comment