This eliminates the double dots:
if (s[i] == '.' && s[i + 1] == '/')
for (j = i; j < strlen(s) + 1; j++)
s[j] = s[j + 2];
Maybe this'll be better to verify there wasn't a preceding dot:
if ((i == 0 || (i > 0 && s[i-1] != '.')) && s[i] == '.' && s[i + 1] == '/')
for (j = i; j < strlen(s) + 1; j++)
s[j] = s[j + 2];
Note: If you want to do this "the right way" you may want to look at lexical analysis and tokenization.
realpath is another option if you can use the available library functions:
reuts@reuts-K53SD:~/cc$ cat test.c
#include <stdio.h>
#include <limits.h> // PATH_MAX
int main(int argc, char ** argv)
{
char rp[PATH_MAX+1];
realpath("/usr/../usr/./bin", rp);
printf("%s\n", rp);
return 1;
}
reuts@reuts-K53SD:~/cc$ gcc test.c && ./a.out
/usr/bin