Robert Peirce wrote:
> In article <bob-A2D57D.21410012022008@[EMAIL PROTECTED]
>,
> Robert Peirce <bob@[EMAIL PROTECTED]
> wrote:
>
>> I just thought of something you Apple experts might know. This has
>> always worked before because t came in memory before n. I am copying
>> s1+TL to n, which is bout 150 characters into a 31 character string.
It
>> is going to trash anything that follows it in memory, which has never
>> been a problem because n always followed t. While this is probably a
>> really dumb assumption, it has worked for 20 years. However, does that
>> actually happen in this case? If t follows n in memory, it would
>> explain why t is getting trashed. It wouldn't quite explain exactly
>> what is getting into t, but it would be a start.
>
> Okay, for the heck of it, I tried this code:
>
> strcpy(t, s1);
> t[TL-1] = '\0';
>
> strcpy(s2,s1+TL);
> s2[SN-1] = '\0';
> strcpy(n, s2);
> printf ("Ticker = %s.\n", t);
> printf ("Name = %s.\n",n);
>
> and it worked. Apparently, t follows n in memory on the Mac and n was
> tra****ng t.
>
> Thanks, everybody, for the tips.
>
You really shouldn't rely on this kind of behaviour. Better to write
robust code and take steps to ensure that you never overrun buffers.
Paul


|