int* arr = new int[30](); //30 is random serving the example's purposes
while(<insert check here that uses the arr pointer>){
cout<<*arr<<endl;
arr++;
}
This is me experimenting on tricks using pointers and I have been working on this for some time today. I have used many different checks in the while clause without ever getting it right (mostly ending up with infinite loops or seg faults). So my question can this be done or the standard for-loop method is the only way?
arr, the only pointer you have to that memory allocation, you've lost the ability todelete[]it without an extreme amount of effort. Make a copy before you start incrementing it.