Subj : Re: Local character strings To : borland.public.cpp.borlandcpp From : maeder Date : Fri Sep 23 2005 07:18 pm "Ray Sittig" writes: > #include > #include > > void main(void); > void PrintText(int version); > > void main() [Not related to your problem: The return type of main() has to be int in a C or C++ program.] > { > PrintText(2); > PrintText(1); > PrintText(2); > printf( "\nPlease press '1' to continue.\n"); > while (true) > { > if (getche() == '1') > break; > } > } > > void PrintText(int version) > { > char* MyText[4] = > {"2 Line Version: Line 1", > "2 Line Version: Line 2"}; As was already posted to in another followup to your post, this initializes an array of 4 pointers with two non-null and two null pointers. Please note that the type of the two character arrays is 'array of 23 char const'. Such an array can only be used to initialize a pointer to char (non-const!) because of a "deprecated" implicit conversion. > int number_of_lines_to_print; > if (version == 1) > { > number_of_lines_to_print = 1; > // once changed - changed for all subsequent calls > // therefore MyText not re-initialized > MyText[0][0] = '1'; This is the reason why the implicit conversion is deprecated. Your code modifies a string literal. This means that the program has undefined behavior. Whatever behavior you see is purely coincidental. With a little more luck, you'd have seen a crash. .