Not a local string (i.e. an array of chars). You can do either of these:
Originally Posted by Abda92
char* str = malloc( 80 * sizeof( char ) + 1 );
strncpy( str, "Hello World", 80 );
return str; /* Now the calling function must free() the string. */
The second method is usually better since the person calling the function knows for sure that they are responsible for memory allocation, plus then they also know the amount of memory allocated.
void func( char* str, unsigned int size )
strncpy( str, "Hello World", (size - 1) );