Is there a fast way in C to get all string until last occurrence of a certain character. for example I have string:
I want the result (until last .):
Here number of slash is dynamic also file name might be in any legal format ( including special chars and white space).
Thanks in advance,
Last edited on
I found my answer. Thanks!!!!
In case someone may need
char * pch;
char pathWoExt; // path without extention
pch = strrchr(full_path,'.'); // finds last occurrence of .
/* partial copy until specified char which is . in this case */
strncpy ( str3, full_path, pch-full_path);
str3[pch-full_path] = '\0'; /* null character manually added */
why not use c++ with <string>?