Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer > Re: Something i...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 12 Topic 995 of 1039
Post > Topic >>

Re: Something is stepping on something

by Paul Russell <prussell@[EMAIL PROTECTED] > Feb 13, 2008 at 09:51 AM

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
 




 12 Posts in Topic:
Something is stepping on something
Robert Peirce <bob@[EM  2008-02-12 22:55:42 
Re: Something is stepping on something
Reinder Verlinde <rein  2008-02-13 00:19:07 
Re: Something is stepping on something
Robert Peirce <bob@[EM  2008-02-13 02:19:37 
Re: Something is stepping on something
Gregory Weston <uce@[E  2008-02-12 20:37:55 
Re: Something is stepping on something
Sean McBride <cwatson@  2008-02-12 21:34:38 
Re: Something is stepping on something
Robert Peirce <bob@[EM  2008-02-13 02:41:00 
Re: Something is stepping on something
Robert Peirce <bob@[EM  2008-02-13 02:48:56 
Re: Something is stepping on something
Paul Russell <prussell  2008-02-13 09:51:12 
Re: Something is stepping on something
Robert Peirce <bob@[EM  2008-02-14 14:12:00 
Re: Something is stepping on something
Paul Russell <prussell  2008-02-14 14:23:31 
Re: Something is stepping on something
Robert Peirce <bob@[EM  2008-02-14 17:36:16 
Re: Something is stepping on something
Reinder Verlinde <rein  2008-02-14 18:43:59 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 17:39:09 CDT 2008.