why is this?

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
we can't as we don't see what your code do from two lines.
^^ use the code tags(Bottom right corner "<>") to edit your post with the code.
Topic archived. No new replies allowed.