|
머냐 님이 쓰신 글 :
: MSDN을 찾아보니 ExtractFileName이게 안나오는데여
:
: 사용법이 어떻게 되죠??
:
: 검색을 해보니 델파이나 PHP에서 사용하던데
:
: C++에서는 어떻게 사용하죠???
ExtractFileName함수는 볼렌드 델파이와 C++빌더에서만 제공하는 함수입니다.
C++빌더를 사용하시면 사용하실수 있고요
Visual C++이라면 _splitpath함수를 사용해 보세요.
이 함수는 visual C++, 빌더 다 지원합니다. 도움말에 있는 예제를 적습니다.
#include <dir.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char s[_MAX_PATH];
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char file[_MAX_FNAME];
char ext[_MAX_EXT];
/* get current working directory */
getcwd(s,_MAX_PATH);
if (s[strlen(s)-1] != '\\')
/* append a trailing \ character */
strcat(s,"\\");
/* split the string to separate elems */
_splitpath(s,drive,dir,file,ext);
strcpy(file,"DATA");
strcpy(ext,".TXT");
/* merge everything into one string */
_makepath(s,drive,dir,file,ext);
/* display resulting string */
puts(s);
return 0;
}
|