Hello,
I have a big problem with pointers and strings -- it seems that I cannot compare string with another string. In the code snippet below, i am trying to compare normal. with whatever value is in the word variable at the moment. If there is a "normal." then the script ouputs 0, if not, then an 1.
The problem is that where the script should output 0, it outputs 1. And where there it should output 1, it outputs 1 (no problem here).
The code deals with the input of many lines, each line having 42 fields separated from each other by comma. The code finds the 42nd field which contains either normal. value or any other word with dot at the end.
What should I do? Please help ASAP: please answer on the same day this message was posted.
Code:for(a=0; !infile.eof();){ // read in one line char *p; char word[20] = ""; infile.getline(buff,200); p = strtok(buff,","); for(int i=0; i<42; i++) { if(i==41) { strcpy(word,p); if (word=="normal.") { cout<<"0"; outfile<<"0"; } else { cout<<"1"; outfile<<"1"; } } p = strtok(NULL,","); } cout<<endl; outfile << endl; a++; }