Home c++ Expression should have a pointer type to an object (array) C++

Expression should have a pointer type to an object (array) C++




Error in check_if_orderable : the expression should have a pointer type to an object.
I do not understand how to specify this type? I understand that you need to put something in front of the ARR (something. Marr [0]), and how it does not enter.

and in main check_if_oderable (arr); says ARR is not defined.

I understand that I don’t get a garbage, but I can not stop. Help me please. )

/ * 4. Make a subroutine that checks the specified array from n numbers to orderly
Ascending (k = 1 - if an array is ordered, k = 0 - otherwise).
With its help, in the main program, process two arrays and one that is not ordered -
reset (using another subroutine). * /
#Include & lt; iostream & gt;
Using Namespace STD;
#Define N 7 // Number of numbers in the array
Void Check_IF_ORDERABLE (INT & AMP; ARR); // Check array is ordered
  Check_if_orderable (ARR);
  Return 0;
  INT ARR [N] {};
  int i;
  for (i = 1; i & lt; = n; i ++)
    COUT & LT; & LT; "Please Enter Some Number" & lt; & lt; i & lt; & lt; ":";
    CIN & GT; & GT; Arr [i];
  int i;
  for (i = 1; i & lt; = n; i ++)
    int prev, next;
    Prev = Arr [0]; // Error: the expression must have a type of pointer to the volume
    next = Arr [1]; // Error: the same
    if (prev & lt; next)
      prev = Arr [i + 1]; // Error: the same
      next = Arr [i + 1]; // Error: the same
      COUT & LT; & LT; "This Array Is Not Orderable.";

Answer 1, Authority 100%


void check_if_orderable (int & amp; arr)

Means the Chtio You pass to the link int function, and not a pointer, as you probably thought (here & amp; – Not taking the address).

You need to just replace & amp; on * :

void check_if_orderable (int * arr)

So, as it is written with you – you are trying to turn to an integer as a massif, which is meaningless. What is the third element of the number 5? 🙂 This is about it and says the compiler – that there should be a pointer.

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