路径分割函数 _splitpath_s()

可以对字符串路径进行分割:

在这里插入图片描述

#include <stdio.h>
#include <windows.h>
#include <cstdlib>  

#include <iostream>
using namespace std;

int main()  
{
    
      
	char* path="C:\\服务程序\\MDTest\\地形\\tileset.json";  
	char drive[5];  
	char dir[100];  
	char filename[100];  
	char fileext[10];  
	_splitpath(path,drive,dir,filename,fileext);  
	cout<<"filepath: "<<path<<endl  
		<<"drive: "<<drive<<endl  
		<<"dir: "<<dir<<endl  
		<<"filename: "<<filename<<endl  
		<<"fileext: "<<fileext<<endl;  
	system("pause");  

	return 0;  
} 

猜你喜欢

转载自blog.csdn.net/m0_37251750/article/details/121247433