James Kanze
10/7/2008 11:10:00 AM
On Oct 7, 2:29 am, Ian Collins <ian-n...@hotmail.com> wrote:
> Neel wrote:
> > 'm getting weird output with strcmp function.
> > 'm unable to detect the error.
> > code is:
> > string myline="[init]";
> > line=myline.c_str();
> What is line?
> > line[strlen(line)]='\0';
> myline.c_str() returns a const char*, if you are attempting to
> modify that data, all bets are off.
And even if it was a copy: if line is correctly '\0' terminated,
this line isn't necessar, and if it isn't, strlen doesn't work.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34