On Tue, Aug 17, 2010 at 10:01 AM, Alex yu <[email protected]> wrote: > pointer has to deal with memory problem, if it is allocated inside the > function.
The solution to that being either 1) Don't allocate it to begin with 2) Free it before returning with NULL. whichever's easier. > 2010/8/17 Benjamin Scott <[email protected]> > >> >> >> A return value of Null is a good return value for failure! >> However, a Integer indicating how many people records match may be good >> too. >> >> So in your opinion which option is best for your program??? >> >> --- On Sat, 8/14/10, Alex yu <[email protected] <vitrun%40gmail.com>> >> wrote: >> >> From: Alex yu <[email protected] <vitrun%40gmail.com>> >> Subject: [c-prog] return type >> To: "c-prog" <[email protected] <c-prog%40yahoogroups.com>> >> Date: Saturday, August 14, 2010, 7:51 AM >> >> >> >> >> provided with a struct: >> >> struct Person{ >> >> char name[10]; >> >> unsigned int id; >> >> }; >> >> and a function : >> >> Person get_person( int) >> >> if the check in get_person failed, what should get_person return? >> >> for example >> >> if(int <0){ >> >> return #Oh, what should I return? >> >> } >> >> [Non-text portions of this message have been removed] >> >> [Non-text portions of this message have been removed] >> >> >> > > > [Non-text portions of this message have been removed] > > > > ------------------------------------ > > To unsubscribe, send a blank message to > <mailto:[email protected]>.Yahoo! Groups Links > > > > -- PJH
