Question: I'm working on an assignment which involves updating the size of a dynamic array to store repeated inputs, with a value of -1 signifying the end of input. When I use this code:

```
    bool end = false;
    int curr;
    int n = 0;
    int* currArr = new int[n];
    int* temp = NULL;
    while (end == false) {  
        cin >> curr;
        if (curr == -1) {
            end = true;
        }
        else {
            n++;
            int* temp = new int[n];
            temp = currArr;
            temp[n - 1] = curr;
            currArr = temp;
        }
    }
    delete[] currArr;
    delete[] temp;

```

am I defining a memory address for temp, changing what is stored at that address during each iteration, then cleanly deleting the contents of that address at the end?

Or am I allocating a new dynamic array during each iteration, only deleting the array defined in the final iteration, and leaking the rest? If so, how would I avoid that?

Similarly, if I define a dynamic array within a function like so:

```
int* fxn(int size) {
    int* x = new int[size];
    return &x[0];
}

int main() {
    int* y = fxn(size);
    delete[] y;
    return 0;
}

```

My understanding is that deleting y will delete the array because y is pointing to the same address that x pointed to within the function. If fxn were a void function, x would need to be deleted within fxn, because fxn would not output any information to the main with which to locate x.

Am I understanding it correctly?

Thanks!

Answer: 
I have not used `xlsx2csv` before but why don't we try `pandas`.

Your requirement can be solved like this:

```
import pandas as pd
for sheet in ['Sheet1', 'Sheet2']:
    df = pd.read_excel('my.xlsx', sheetname=sheet)
    df.to_csv(sheet + '_output.csv', index=False)

```
You can do something as the follows:

```
import pandas as pd

xls_file = pd.ExcelFile('<path_to_your_excel_file>')
sheet_names = xls_file.sheet_names

for sheet in sheet_names:
    df = xls_file.parse(sheet)

```