As the title suggests, how to return pointer like this:
xxxxxxx foo() {
static int arr[5][5];
return arr;
}
BTW. I know that I must specify the size of one dimension at least, but how?
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.
It helps to use a typedef for this:
If you don’t want a use a typedef for some reason, or are just curious about what a naked version of the above function would look like, then the answer is this:
Hopefully you can see why using a typedef is a good idea for such cases.