Hi friends,
'm getting weird output with strcmp function.
'm unable to detect the error.
code is:
string myline="[init]";
line=myline.c_s tr();
line[strlen(line)]='\0';
char *value=strtok(l ine,"=");
cout<<strlen(va lue)<<endl;
if(strcmp(value ,"[init]")==0){
cout<<"found"<< endl;
}
even though the value assigned to line is "[init]" (and it prints too
when I do cout) but it doesnt display "found" (satisfy if condition)
'm getting weird output with strcmp function.
'm unable to detect the error.
code is:
string myline="[init]";
line=myline.c_s tr();
line[strlen(line)]='\0';
char *value=strtok(l ine,"=");
cout<<strlen(va lue)<<endl;
if(strcmp(value ,"[init]")==0){
cout<<"found"<< endl;
}
even though the value assigned to line is "[init]" (and it prints too
when I do cout) but it doesnt display "found" (satisfy if condition)
Comment