Mail Archives: djgpp/2001/03/21/04:00:16
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 -