Say I have to remove the last occurrence of a string from another string. How would I go about it?
To elaborate, I have a file name in a c string (gchar* or char* )
C:\SomeDir\SomeFolder\MyFile.pdf
and I want to remove the extension .pdf , and change it to something else, e.g .txt or .png . What is the least troublesome yet efficient , convenient and cross-platform way to do it? Thanks.
note: I know this is an extremely simple thing to do in C++ but for this project , I absolutely MUST use C and no other language. (academic requirement)
note 2: Although you can suggest other third-party library , I currently only have access to the C standard library and the GLib.
note 3: I have searched for similar questions with the “C” tag, but can’t seem to find any.
1 Answer