I have this code
class here
{
public:
int h;
int b;
};
---> main program <----
here array[10];
lol(&array);
void lol (here *array);
{
array->h
}
this code points only to the first memory blocks of the array like [0]. how do i do it that i can use other ones lke [1],[2],[3] if there was data in them?
Looked at them and still no idea how to do it cuz if i say something like (array)++ it will only give the the [1] value and not all the values in the array
Arrays without their [brackets] can be cast to a pointer to the first element.
Furthermore, using [brackets] on a pointer treats the pointer as if it were an array. Therefore for the most part arrays and pointers can be used the same way:
1 2 3 4 5 6 7 8 9 10 11 12 13
void lol(here* array)
{
array[0].h = 0; // access [0] element
array[1].h = 1; // access [1] element
}
//...
int main()
{
here array[10];
lol(array); // no need for & operator
}