The codes I’ve tried to run
I’m relatively new to C++ and am eager to delve deeper into this fascinating programming language. Recently, I attempted to write a program that stores an unknown number of integers in a pointer allocated on the heap. However, I encountered confusion when trying to read integers from standard input and store them at the i-th position of the ‘nums’ pointer. Specifically, using (nums + i) as the address of the i-th position led to a compile error, while *(nums + i) which I believe represents the value at the i-th position worked while didn’t expected. I’ve included code snippets below for better clarity.