Reputation: 357
Using ftw()
function, I have a list of paths I want to write on a file.
I need only paths starting from a specified folder, like:
source folder: /Users/me
subfolder1: /Users/me/school
subfolder2: /Users/me/school/english
result I need: /school
/school/english
Is there a way to "subtract" one string from another, in the way i explained above? I know there is strtok()
function, but i don't know if it works with more than one char at a time.
Thanks.
Upvotes: 1
Views: 2561
Reputation: 2316
If you are sure that the prefix is there, just skip it:
char *result = subfolder + strlen(source);
Upvotes: 3