It's more of a conversation topic that a question. Look at the following code for calculating the nth Fibonacci number and print out all of them up to the nth(namespace std pressumed and the following is in the main):
int n=20;
int *a=new int; //notice NO size declaration
a[0]=1;
a[1]=1;
for(int i=2; i<n;i++){
a[i]=a[i-1]+a[i-2];
}
for(int i=0; i<n;i++){
cout<<a[i]<<endl;
}
So should it work? Does it work for you? Any comments as to whether it wouldn't work for someone? Thank you in advance. That's my personal method to allocate memory dynamically in 1D, but I can't find any documentation with this method, and I've been using it forever. Of course, I don't do the same on 2D. Thank you for reading.