a very simple question I am afraid but I have been stuck for days with this, Google gives me nothing, I even tried bing... ;o)
I am working in pure C under windows in VS2010.
I have a static char array as such...
static char word[5];
I can set each array position just fine i.e...
word[0] = 'f'; word[1] = 'o'; word[2] = 'o';
But what I cannot seem to do (at any point after declaration) is...
word = "foo";
Any help or pointers as to where I am going wrong would be very much appreciated.
Thanks all in advance.
strncpy(word, "foo", _countof(foo));
If _countof is not defined, use sizeof(foo) / sizeof(*foo) instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With