Hello everybody!
I have two questions about pointers and would be grateful if someone gave me some help.
1. When we use a table's name as a parameter the table is used as an address (the address of its first element). I mean, when i call a function that has a table parameter :
fill (tab, size);
then parameter tab is used as the address of its first element. If i write:
fill (&tab, size);
then &tab is a pointer to tab's first element address? What does this really mean?
2. If i use new in order to create a dynamic array without deallocating the previous chunk of memory then will that lead to a problem? I mean is it right syntactically the following?
for (int i = 0; i < 10; i++) {
int *tab = new int[size];
for (int j = 0; j < size; j++)
tab[j] = rand();
//delete [] tab;
}
In the example above i fill array tab with random numbers and without deallocating tab i reallocate the specific chunk of memory. This is wrong..isn't it?
Thank you for your time!