This code is showing an error at the cin
statement. Why is this?
Here is the error:
no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int*')
#include<bits/stdc++.h>
using namespace std;
struct go {
int size, *p;
} r;
int main()
{
int sum = 0;
r.size = 10;
r.p = (int*) malloc(r.size * sizeof(int));
for(int i = 0; i < r.size; i++){
cin >> (r.p + i); // this line is showing error
sum = sum + (*(r.p + i));
}
cout << sum;
}