float myArray[myArraySize] = {1};
In the expression above only the first element is init with 1. How can you init all the elements with a value using a compound literals(not memset)?
I’m using GCC 4.2 on unix to compile.
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.
This
is how you do it.
See Designated Initializers in the GCC docs which says: