Lattice/UNIX incompatibility

John Nelson john at genrad.UUCP
Sat Jan 5 02:31:08 AEST 1985


>> 
>> 	7. Identical strings are stored together.  (I doubt that
>> this would cause many problems.)
>> 
>Boy does this cause problems.  My application overwrites the string.
>When I wanted to do it twice I did something like
>	char	*str1 = "../../..";
>	char	*str2 = "../../..";
>

defining these two strings as:

	char	str1[] = "../../..";
	char	str2[] = "../../..";

avoids the problem.  This defines two arrays (seperate storage) initialized
to be the value of the string, rather than two pointers to string storage.

I think that it is rather chancy to overwrite string literals, in any case.



More information about the Comp.lang.c mailing list