Home c++ Expression must be of type pointer to object

Expression must be of type pointer to object

Author

Date

Category

Error: expression must be of type pointer to object. However, as soon as I put the pointer, another error appears. Namely, addressing. Here is the code

# include & lt; iostream & gt;
#include & lt; conio.h & gt;
using namespace std;
void main ()
{
  char w = cin.get ();
  char mem [2000];
  int ptr = 0; int lvl = 0;
  for (int i = 0; i & lt; 1000; i ++)
  {
    switch (w [i])
    {
    case '+':
      mem [ptr] ++;
      break;
    case '-':
      mem [ptr] -;
      break;
    case '& lt;':
      ptr--;
      break;
    case '& gt;':
      ptr ++;
      break;
    case '.':
      cout & lt; & lt; "\ n" & lt; & lt; mem [ptr] & lt; & lt; "\ n";
      break;
    case ',':
      mem [ptr] = cin.get ();
      break;
    default:
      break;
    }
  }
  fflush (stdin);
  cin.get ();
}

Answer 1, authority 100%

# include & lt; iostream & gt;
#include & lt; string & gt;
int main ()
{
  std :: string s; // line
  std :: getline (std :: cin, s); // enter a string through the console
  for (size_t i = 0u; i & lt; s.size (); ++ i)
  {
    // ...
  }
  std :: cin.get ();
  return 0;
}

Where there are ellipsis, write logic

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions