Function that returns an array.

I have some problems with using pointers in Dynamic. What I want is to call a function that returns an array. I tried the following:

char *itpp(int n, char buf[])
sprintf(buf, “%d”, n);
return buf;

void main(){
auto int i;
auto char buf[25];
auto char *str;
i = 23;
*str = itpp(i, buf);

while (1){

But this doesn’t seem to work. Can anybody help me?

bad code:

*str = itpp(i, buf);

good code:

str = itpp(i, buf);

The code you posted writes the base address of buf to some random location in memory, since str is uninitialized. You should have gotten some compile warnings. :wink:

Thanks for your reply! It is solved now :smiley: