puts() a pointer in C

Posted by Sergey Gavruk on Stack Overflow See other posts from Stack Overflow or by Sergey Gavruk
Published on 2010-03-26T20:36:19Z Indexed on 2010/03/26 20:43 UTC
Read the original article Hit count: 311

Filed under:
|

I have a function:

char *make_text(void)
{       
        char txt[MAXLEN];
        //make something
        return txt;
}

Thats my main program:

int main(void)
{
        char *s = make_text();
        puts(s);
        getch();
        return 0;
}

puts(s) returns 0 and its nothing printed. Whats happened?

© Stack Overflow or respective owner

Related posts about c

    Related posts about string