Re: First program in C - what is going on with function returns?



Ok, that does the trick.

I have now moved the program to a linux system which was a bit fussier.
I cleaned up a bit by removing any global vars and making proper use of
function returns.

The program is compiling ok but I receive this warning:

daysalive.c: In function `speakdate':
daysalive.c:92: warning: function returns address of local variable

Is this a problem? Relevant code below.

char *speakdate(int d, int m, int y)
{
<snip>
return datestring;
}

int main(void)
{
<snip>
printf ("Your date of birth is
%s\n\n",speakdate(bdate,bmonth,byear));
<snip>
printf ("The current date is:
%s\n\n",speakdate(cdate,cmonth,cyear));
<snip>
}

.



Relevant Pages

  • Re: Example Needed
    ... [snip OP's drivel] ... sample.c: warning C4127: conditional expression is constant ... PRINTSIZE(signed short int); ...
    (comp.lang.c)
  • Re: Haldanes Dilemma - clarifications - and Felsenstein [LONG]
    ... This sounds like a consequence of the theory of 'nearly neutral' selection. ... We take two at random, and return the one with the highest fitness, ... int choose ...
    (sci.bio.evolution)
  • Re: inline vs macro
    ... char *p = c; ... with this warning: ... int *r = q; ...
    (comp.lang.c)
  • Re: Confused to printf %f
    ... Someone asked me a question about integer division and printf ... You gave it an int. ...
    (comp.lang.c)
  • Re: c interview
    ... undefined behaviour because printf is a varidac function. ... stdio.h before using printf and other headers as appropriate before ... Would make it a point that the size of int is assumption to be .... ...
    (comp.lang.c)