typedef struct {
float *numbers;
float val1;
float val2;
} Values;
Values val[16];
How can one allocate memory for numbers in the struct?
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.
So, you could do this without using dynamic memory allocation like this:
But I can’t think of any reason why you’d want a structure with a pointer to just one float.
Based on the name
'numbers', I’d say you want'numbers'to point to an array offloats, if so, you could do this: