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

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -