代码:
#include <stdio.h>
#include <string.h>void test(const char *paszStr)
{
char *pSearch = (char *)strrchr(paszStr, '/');
if(NULL != pSearch)
{
*pSearch = '\0';
}
return;
}
int main()
{
char sz[] ="my/test/file/touch" ;
printf("old: %s\n", sz);
test(sz);
printf("new: %s\n", sz);
return 0;
}
执行结果:
old: my/test/file/touch
new: my/test/file