Home c Error: expression must be a valid left-sided value. What does the error...

Error: expression must be a valid left-sided value. What does the error mean?

Author

Date

Category

The program should allocate memory for a square matrix

# include & lt; stdlib.h & gt;
bool WidPam (int ** X, int str, int sto)
{
  if (! (X = (int **) calloc (str, sizeof (int *))))
  {
    printf ("Not enough memory \ n");
    return false;
  }
  for (int i = 0; i & lt; str; i ++)
  {
    if (! (/ * The cursor is here * / (X + i) = (int *) calloc (sto, sizeof (int))))
    {
      printf ("Not enough memory \ n");
      return false;
    }
  }
  return true;
}

Answer 1, authority 100%

The error means that the X + i on the left side of the assignment is nonsense. What were you trying to achieve by your trying to assign something in X + i ?

The result of the expression X + i is not an lvalue. You cannot assign anything to it.

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