Thanks a lot, I got it! I spend all day on this stupid problem. I had to change a few things in your code so here is the working version if anyone else cares.
Code:
#include <stdio.h>
#include <string.h>
void sayHi(char **);
int main()
{
char **str;
str = malloc(sizeof(char *)); /* allocate space for the pointer to the pointer to the character */
*str = malloc(6 * sizeof(char)); /* allocate space for the string itself - you could also do this in sayHi */
sayHi(&str);
printf("srt: %s\n", str);
return 0;
}
void sayHi(char **str)
{
char *temp = "hello\0";
strncpy(*str, temp, 6); /* copy the characters pointed to by temp into the ones pointed to by *str - up to a maximum of 6 - we don't want any buffer overflows around here */
printf("str: %s\n", *str);
}