Let us say that I declare and initialize
int a[3] = {1, 2, 3};
How can I later asisgn the entire array in one fell swoop? i.e.
a = {3, 2, 1};
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.
If your c compiler supports compound literals, you can use
memcpy:If you don’t plan to stick any variables in there (you can; isn’t C99 amazing?),
(int[])can be replaced by(const int[])to put the literal into static memory.