A C string is merely an array of char terminated with the nul character, '\0'. strcpy (w, "") will work, but you may as well just write w [0] = '\0';

char *str; does not define a string. It defines a pointer to a string. The pointer is useless, indeed dangerous, if you don't assign it a value that points to an existing string. k=str [i] is only effective if str is an initialized pointer, or the name of an actual char array.

For your next example, if changing w later is changing the temp value, then your snippet is not complete. The implication is that the two are referring to the same array. Rather than write your own loop, why not just use strcpy?

For your next example, if you want to put the 'k' on the end of a string, just use strcat (w, "k");. W must, of course, be long enough to hold the extra character.

Similarly, for your last example, use strcpy (w, "k");

&k is not the character OR the string, "k", it is the address of a variable named k.