prog.cpp:53:15: error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]
prog.cpp:26:6: error: initializing argument 1 of ‘void sortiraj(int*, int)’ [-fpermissive]
The problem is that you're trying to pass an int into a function, but you've defined the function to take an array of ints.
Plesase, what shoudl I do? HOw to correct it?
I am trying to pass to the function one array AND one int!!!
Then pass the array and not an element from the array. In other words, drop the element access operator '[]' when you're passing the argument.
Then pass the array and not an element from the array. In other words, drop the element access operator '[]' when you're passing the argument. |
Exactly.
In fact,
z[40] isn't even an element of the array. It would be the 41st element of the array, but the array is only defined to have 40 elements:
... so it's beyond the end of the array.
Also, enemy, what's the point of:
1 2 3
|
return str;
delete[]str;
}
|
? When the
return statement executes, that function ends - the
delete statement will never be executed.
And lucky for you that it isn't executed, because if it was, it would delete the memory allocated to the array, so the pointer becomes invalid.
Last edited on
Hello!
U just opened another question I wanted to ask!!!
This is the nice example for q, we SHOULD delete the stuff, but we do not want.
Please, how to solve this problem???
(ps.. I knew what I wanted to achieve when I wrote it...but this sounds very tricky for me...)
Many thanks!!!