How do you make all elements = 0 in the array sent as a parameter?
int myArrayFunction(int p_myArray[]) {
p_myArray[] = {0};//compiler error syntax error: ']'
.
.
}
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.
No you can’t. There’s not enough information. You need to pass the length of the array too.
Then you can use
memsetorstd::fillto fill the array with zero. (= {0}only works in initialization.)Alternatively, switch to use a
std::vector, then you don’t need to keep track of the length.