C - Setting a static char array with a "string" -
a simple question afraid have been stuck days this, google gives me nothing, tried bing... ;o)
i working in pure c under windows in vs2010.
i have static char array such...
static char word[5]; i can set each array position fine i.e...
word[0] = 'f'; word[1] = 'o'; word[2] = 'o'; but cannot seem (at point after declaration) is...
word = "foo"; any or pointers going wrong appreciated.
thanks in advance.
strncpy(word, "foo", _countof(foo)); if _countof not defined, use sizeof(foo) / sizeof(*foo) instead.
Comments
Post a Comment