#include<iostream>
using namespace std;
int main() {
int *p=new int [10];
}
After creating the array, I am confused and want to know if it's possible to do the following:
- read an array of integers without builtin arrays such as vector.
- print out this array.
- Is there any built-in command that we can use in cpp to get the actual size of the array, which means we don't have to use sizeof(*p)/size(p[0]).
And what do you think will be the easiest way of doing this task, on the condition that we still use the pointer of an array.
Thanks for helping me out!
int *p=new int;this will get you only one dynamically allocated integer variable, if you want an array you would useint *p=new int[10];for an array of 10 integerscout << "index 5:" << p[5] << endl;I think that the loop is a way to go. Why do you need to avoid the loop?