why is this?

Mar 20, 2012 at 3:36am
I just found out something unnusual:

I have a constructor that sets a name and allocates memory for a number of objects of another class -

If I write:
strcpy(name,"NAME");
allocate = new class2(i);

the name of the robot changes, but in the main when i call get_name, only a few of the last chars are printed, or a new string is given with unnusual letters (those with dots above etc)

however, if i would invert the above order, the returned name is what i set it to be

can someone explain this?

Last edited on Mar 20, 2012 at 3:37am
Mar 20, 2012 at 5:29am
we can't as we don't see what your code do from two lines.
Mar 20, 2012 at 5:52am
^^ use the code tags(Bottom right corner "<>") to edit your post with the code.
Topic archived. No new replies allowed.