I'm trying to scroll through a list of cstrings and if they end in an 's' I want to replace it with a '\0' the problem is somtimes it catches the word and corrects it for a comparison, but other times it doesn't

 while (ptr != NULL)
    {
       if(ptr[sizeof(ptr)] == 's')
        {
           ptr[sizeof(ptr)] = '\0';
           ptr = ptr;
        }
          (binarySearch(dictionary, ptr) == false);// ? cout << ptr << " misspelled on line " << line << endl: cout << "" << endl;
        ptr = strtok(NULL," ;.");


    }

Input file:
Razors pain you;
Rivers are damp;
Acids Stain you;
And drugs cause cramp.
Guns aren't lawful;
Nooses give;
Gas smells awful;
you might as well live.

out put:

word:razors last char r

word:rivers last char r

word:guns last char

word:nooses last char e

Process returned 0 (0x0) execution time : 0.734 s
Press any key to continue.

I feel like I've asked too many questions today, but this one is killing me, I've hit a point where I'm clueless (more than usual) there's no leading or trailing white spaces, delimeters or any other folderal encumbering these words, but on some words it hiccups, and is you look at 'guns' it doesn't anything. Any explantion for this inconsistancy in lengths?

needed strlen() not sizeof()

You will also need to subtract 1 from the length to get the index of the last character.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.