N
Neel
Hi friends,
'm getting weird output with strcmp function.
'm unable to detect the error.
code is:
string myline="[init]";
line=myline.c_str();
line[strlen(line)]='\0';
char *value=strtok(line,"=");
cout<<strlen(value)<<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_str();
line[strlen(line)]='\0';
char *value=strtok(line,"=");
cout<<strlen(value)<<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)