Subj : Re: Sending catenated cstring strings to the printer To : borland.public.cpp.borlandcpp From : maeder@glue.ch (Thomas Maeder [TeamB]) Date : Sun Feb 29 2004 09:43 am "George Tamero" writes: > // write string to printer > int Printer_Print(string inptString) > { // write returns 0=success, 1=trouble > char* whatToPrint=""; This variable definition is only accepted because of a deprecated implicit conversion from 'array of 1 char const' to 'pointer to char' (non-const!). The reason why this is deprecated is that the array might very easily be overwritten, which would cause the program to have undefined behavior. > strcpy(whatToPrint, StringToArray(inptString)); And this is an example. If inptString.size() is !=0, your program has undefined behavior. > if(fputs(whatToPrint, file) != EOF) Better simplify the function to: if (fputs(inptString.c_str(),file)) > return 0; > > return 1; , or, better yet, the entire function to return fputs(whatToPrint,file) != EOF; .