How to get size of a dynamic allocated array of ints in C++?
Example:(/this will always give 4 as 4 * 8 = 32bits it’s size of int)
bool tabSum(int* t, int& p, int& np){
cout<<"\n\n";
cout<<sizeof(*t)<<endl;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t, arrays decay to pointers when passed as parameters. And
sizeofis a compile-time operator.I suggest you use
std::vectorinstead.