S
Sean Berry
I need to find the second to last occurence of a "." in a string.
Basically I am taking a URL like
http://this.is.mydomin.com/path/to/file.txt
and want to extract /path/to/file.txt
I thought I would be able to do it like this:
----------------------------------------------------
char *cd = (char *)NULL;
if (strstr(short_database, "http") != (char *)NULL) {
cd = strrchr(short_database, '.');
cd = strchr(cd, '/');
strcpy(short_database, cd);
}
---------------------------------------------------
But, since there is a "." in ".txt", this will not work.
So I need to repeat the call to find the second to
last instance of ".".
Can anyone help. Thanks in advance, and sorry about
the seemingly easy questing... I am not a good C programmer,
yet!
Basically I am taking a URL like
http://this.is.mydomin.com/path/to/file.txt
and want to extract /path/to/file.txt
I thought I would be able to do it like this:
----------------------------------------------------
char *cd = (char *)NULL;
if (strstr(short_database, "http") != (char *)NULL) {
cd = strrchr(short_database, '.');
cd = strchr(cd, '/');
strcpy(short_database, cd);
}
---------------------------------------------------
But, since there is a "." in ".txt", this will not work.
So I need to repeat the call to find the second to
last instance of ".".
Can anyone help. Thanks in advance, and sorry about
the seemingly easy questing... I am not a good C programmer,
yet!