delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/21/04:00:16

Date: Wed, 21 Mar 2001 11:11:31 +0530 (IST)
From: Mridul Muralidharan <ec97027 AT matrix DOT reccal DOT ernet DOT in>
To: sager+@andrew.cmu.edu
cc: Djgpp mailing list <djgpp AT delorie DOT com>
Subject: Re: newbie error, or are my pointers fuxing
In-Reply-To: <Yui0j=i00UjLEHS0Uq@andrew.cmu.edu>
Message-ID: <Pine.LNX.4.04.10103211107310.11040-100000@matrix.reccal.ernet.in>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

i tried the code that u mentioned and did not get any seg faults !
maybe , with some other string longer than 40 char's , u are getting this
error :)

Mridul Muralidharan
S8 Electronics and Communication
Regional Engineering College
Calicut
India

------------------------------------------------------------------------------

If the code and the comments disagree, then both are probably wrong.
                -- Norm Schryer

All generalizations are false, including this one.
                -- Mark Twain

/earth is 98% full ... please delete anyone you can.

	- fortune

On Tue, 20 Mar 2001, James W Sager Iii wrote:

> I had a problem earlier with pointers messing my game up.
> 
> I'd send 1 adress to a function, but it'd recieve a different one. 
> Really weird stuff...
> 
> Anyway, I was wondering:
> 
> 
> void stupid_newbie function(char *c1)
> {
> char a[40];
> 
> strcpy(a,c1);
> 
> cout<<a;
> }
> 
> If I pass:
> 
> stupid_newbie_function("Hello.");
> stupid_newbie_function("world.");
> 
> It will type: Hello
> then a Segfault pops up.
> 
> if I do:
> char b[40];
> strcpy(b,"Hello");
> stupid_newbie_function(b);
> strcpy(b,"World");
> stupid_newbie_function(b);
> 
> It gives me:
> HelloWorld
> 
> 
> So is this me being a stupid rusty programmer?
> Or is it due to my program having a memory leak I still need to track down?
> 
> 
> I haven't got back in my groove yet... still mega rusty
> All I want to do is design games, I hate code.
> 
> 
> Thanks for reading,
>                 James Sager
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019