Re: problems with char * return from a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 11, 2008 at 08:52:13PM -0400, Vardhan, Sundara (GE Infra, Energy) wrote:
> Hi All
> 
> I am calling a function x within strcpy as follows
> 
> strcpy(a,x("sample text","default text"));
> 
> x is defined as follows
> 
> char * x(char *m, char *n)
> {
> 	char *return_val=NULL;
> 	if (check m is in database)
> 		return_val=m;
> 	else
> 		return_val=n;
> 	return(return_val);
> }

I see no problem with this code and writing a testcase based on it works
for me.  I think your problem is elsewhere.  Can you boil this down to a
self-contained program, including main() and everything, that exhibits
the incorrect behavior, which we can compile and test ourselves?  If
this does not reveal your bug, please post it with the version of GCC
you are using as well.

Thanks,
Dan

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux