Does strcat work w?

Helllo everyone,

I am using version 401/01 compiled for win32.

I have problems using strcat. The following little script does not work and I have no clue why… Maybe it is obvious, but apparently I am blind at this moment…

{
gROOT->Reset();

Char_t *a = “bla”;
Char_t b[32] = “blo”;

strcat(b,a); // I expect blobla as output

}

I get an error message that the memory can’t be read and my root session is ended.

Thanks for your help

Marc

You stry to copy the 33 characters of b (including the null character)
to the array a with only 4 characters !!

Rene

Hello,

Even if I invert the order in the strcat function and fix the size of the array, I get the same error.

Marc

This is a very basic C programming mistake.
Please send a concrete piece of code, so that we can diagnose where
you make the error.

Rene

Ok, here it is:

{
gROOT->Reset();

Char_t a[10] = “bla”;
Char_t *b = “blo”;

strcat(a,b);

}

These are not the first lines of C code I am producing and I have used this quite often, but never in Root. Moreover, if I run this from Microsoft Visual C, it works fine… The output is “blablo” as expected. Therefore my question.

Marc

Hello Marc,

on my ROOT-system (LINUX ROOT v400-04) your code runs whitout any problems (both code-examples).

Can you test your code on any other ROOT-version or OS?

Carsten.

Hi Carsten,

I am running win2k and, unfortunately, no other option concerning the os.

Thanks,

Marc

Hi,

I can not reproduce the problem on windows XP or win2k.

Cheers,
Philippe.

Hi,

Then I guess that my Root installation must be screwed somehow…

I’ll have to fix it.

Thanks for your time!!

Cheers.

Marc

I finally reproduced the problem when using an optimized build.
It seems that it is due to a bug in the MSVC7 optimizer, a work-around will be uploaded to the CVS repository very shortly.

Cheers,
Philippe.