2014-04-23:去掉路径最后的反斜杠

来源:互联网 发布:java servlet上传图片 编辑:程序博客网 时间:2024/06/05 11:50
#include <stdio.h>#include <tchar.h>#include <string.h>#include <windows.h>LPTSTR DeleteBlackslash(LPTSTR lpProfilePath){DWORD dwPathLength = 0 ; dwPathLength = _tcslen(lpProfilePath) ;printf("length:%d",dwPathLength);if ( lpProfilePath[dwPathLength-1] == TEXT('\\') ){lpProfilePath[--dwPathLength] = (TCHAR)0 ; }return lpProfilePath;}DWORD _tmain(int argc,LPTSTR argv[]){LPTSTRlpProfilePath = NULL ;TCHARszProfilePath[MAX_PATH+1];if (argc<2){return 1;}_tcscpy(szProfilePath,argv[1]);lpProfilePath = DeleteBlackslash(szProfilePath) ;printf("Primary:%s\nNew ProfilePath:%s",argv[1],lpProfilePath);return 0;}

0 0
原创粉丝点击