OK, an attempt for a more serious reply.
The first reply was trivial, because of the very vague and contradictionary question.
Fred Zwarts said:
Mike said:
Hi
of a char: char filepath[255];
I should remove the last two words: lin.xpl
What exactly do you think defines the term "word" here.
Words are normally separated by word separators.
What do you consider a word separator?
Only a '.', as in the example, or also a '-', a '/', a ' ', a '_', etc.?
Are you sure that you always want to remove the last two words?
Even in the case that the string is e.g.
"/ect/bla.conf.original" -> "/etc/bla."
or "/etc/init.d/rc5.d/S10product" -> /etc/init.d/rc."?
or "/usr/local/bin" -> "/usr/".
What if there is a word separator at the end, or if there are two successive word separators as in "/etc/..".
This suggests that you do not want to remove the last two words,
but everything following the last '/', which is something very different.
(But you do not say so.)
Do you only want to consider the '/', or also the '\' (as it is used in Windows)?
First try to formulate what you want to do exactly.
Then see if you really want to do this with an array of char with a fixed length,
or with the more flexible std::string type, which has methods to find the
first, or the last position of a given set of characters within the string,
to extract substrings, and more string manipulation methods.