Reinitialize array in function


inside called function want reassign char array, compiler complains
"expected primary-expression before ']' token".

essentially code looks this

static char char_array[]="aaaa";
//change entries of char_array
if (some condition) char_array[] = "aaaa"; //reset char_array here error occurs.


of course 1 iterate on each character in array, isn't there better way?

there number of ways reset defined array. work:

code: [select]

if (some condition) {
   memcpy(char_array, "aaaa", sizeof(char_array));
}


edit: bad, ray.


Arduino Forum > Using Arduino > Programming Questions > Reinitialize array in function


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code