F
F
funny4badger2020-02-13 00:06:40
C++ / C#
funny4badger, 2020-02-13 00:06:40

The expression must be of type object pointer. What is the essence of the error?

#include <stdio.h>        
#include <stdlib.h>
#include <time.h>

int fillFunction(arr, i, j)
{
  for (i = 0; i < 11; i++)
  {
    for (j = 0; j < 11; j++)
    {
      arr[i][j] = random(51) - 25;         // тут ошибка(i подчеркнуто)
    }
  }
}


int main()
{	
  int i, j;	
}


I can not understand what the error in line 11 means "The expression must be of the type of a pointer to an object"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CityCat4, 2020-02-13
@funny4badger

I have to agree with Illia Nezhyhai - this code is one big mistake :) And the main mistake is that the function parameters have no type, and therefore the compiler assumes that they have the int type (for C, there is no default type in C ++, attempting to compile this code will result in an error). Therefore, of course, the expression arr[i][j] = something there will be incorrect.
Firstly, all function parameters should always be typed - this will save you from such ridiculous mistakes and remind you what is being passed to the function if you don’t write a comment describing it out of your own laziness
Secondly, documenting the passed parameters and assigning normal names to variables, and not i, j, k - will help both others who will read your code, and you yourself - when you get into it in a year.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question