Apart from the previously mentioned issues, your function will always return an empty string:
char temp[32] = "";
This reserves a char array on the stack and initializes it with the empty string, i. e.
temp[0] = 0;
sprintf("%c:%c:%c:&c:%c:%c", temp[0],
);
This command copies temp[0] to temp[0], so it stays at 0. (of course, you might in fact have meant to copy
pointer[0]
into
temp[0]
here?)
str = temp;
This assigns the string represented by
temp
to str. Since
temp[0] == 0
,
temp
represents the empty string, so
str
will be empty too.
Maybe you are mistaking the term 'memory leak' with the seemingly inexplicable vanishing of your input? Just so we can be sure we're talking about the same things:
This is the definition of a memory leak[
^]