Need Help on Using cin With Arrays

Hey, this is my first post on this forum so I'm not exactly sure how to format the code (or whether this is the right place to post, but I think it is...)
If I've broken any guidelines, please tell me! Thanks.

Anyway, I have a code written to receive input from a user. What this program is supposed to do is assign every other value entered by the user as a double and all operators as a char. Later, the chars will be compared to decide on PEMDAS, etc...

However, I keep getting an error when I compile. I've searched for this error on other posts, but I can't find a solution that works (for me). I think this may be because of the cin putting a value into a double array that uses an int for its element number, but I'm not sure. Can anyone help me solve this?

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include "operdecide.h"
#include "calculator.h"

using namespace std;

double calculator()
{
  double param[50] = {0};
  char ops[50] = {0};
  double answer;
  int n = 0;
  int x = 0;
  cin
    >> param[x]
    >> ops[n]
    >> param[x + 1]
  ;
  ++x;
  while(cin.get() != '\n')
  {
    cin
      << ops[n]
      << param[x]
    ;

    ++n;
    ++x;
  }

  answer = operdecide(param, ops);

  return answer;

}


Error:
calculator.cpp:35:7: error: invalid operands to binary expression ('int' and 'double')
<< param[x]
^ ~~~~~~~~
On lines 23 and 24, that's not the extraction operator.
Use >> on line 23 and 24 instead of <<.
Topic archived. No new replies allowed.