Re: Function Problem
- From: "Chris Tacke, eMVP" <ctacke@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Apr 2005 12:50:32 -0400
And the whole thing is non-Unicode, which may (or may not) be a problem.
--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate
"Bruce Eitman (eMVP)" <beitmannospam@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:O2de65ATFHA.548@xxxxxxxxxxxxxxxxxxxxxxx
> Helge is correct, you *cannot* return pointers to data on the stack and
> expect that the data is valid after the return. Either dynamically
> allocate
> a buffer at runtime or modify the original string.
>
> But you have more problems than that.
>
> Isl_Total takes paramters that are pointer to strings of undefined length,
> but fnReplace takes pointers to strings of length 16. This inconsistency
> could bite you later on when you least expect it.
>
> See below, error checking and freeing is left to you.
>
> extern "C" void _cdecl Isl_Total(char x[], char y[], char *res)
> {
> char *s = malloc( strlen(y));
> char *t = malloc( strlen(x));
>
> strcpy( s, y );
> strcpy( t, x );
>
>
> fnReplace(s);
> fnReplace(t);
> double xx =atof( s ), yy= atof( t );
> double result;
>
> result = xx + yy;
>
> _gcvt( result, 7, res);
>
>
> }
>
> ///////////////////End/////////////////////////////
>
>
> ////////////////Second Function/////////////////////////
> void fnReplace (char *RplStr)
> {
> char find = ',';
> char replace = '.';
> char string[16];
> int len,i;
>
> len = strlen( RplStr );
>
> for (i=0;i<=len;i++)
> {
> if ( RplStr[i] == find )
> RplStr[i] = replace;
>
> }
> }
> //////////////////////End/////////////////////////////
>
>
>
>
> --
> Bruce Eitman (eMVP)
> Senior Engineer
> beitman AT applieddata DOT net
>
> Applied Data Systems
> www.applieddata.net
> An ISO 9001:2000 Registered Company
> Microsoft WEP Gold-level Member
>
>
> "Helge Kruse" <Helge.Kruse-nospam@xxxxxxx> wrote in message
> news:%23tdqew$SFHA.3312@xxxxxxxxxxxxxxxxxxxxxxx
>> Dont know, what "does not work" means, but...
>>
>> your function fnReplace returns the address of the auto variable
>> "string".
>> That doesn't work.
>>
>> Regards, Helge
>>
>>
>
>
.
- References:
- Function Problem
- From: Thrax
- Re: Function Problem
- From: Helge Kruse
- Re: Function Problem
- From: Bruce Eitman \(eMVP\)
- Function Problem
- Prev by Date: Re: GetFont() not working ...
- Next by Date: Re: Some questions; SHMenuBar, multilingual prog
- Previous by thread: Re: Function Problem
- Next by thread: _ecvt, _gcvt and _fcvt problem
- Index(es):
Relevant Pages
|