Re: using local buffers.

From: Scatter (scatter@onramp.net)
Date: 09/29/95


> Btw, I know I can 'return "string"' in order to return a string from a 
> char* function, but if I have a local buffer, how would I return a string 
> in the same manner without returning the address of the local buffer?

char *some_fun(char *str){
    char my_buf[SOME_LENGTH];

    strcpy(my_buf, str);
    return(strdup(my_buf));
}

A worthless piece of code that should answer your question.

/*  I hate posting code, cuz I'm just too damn insecure :) */



This archive was generated by hypermail 2b30 : 12/07/00 PST