Red de conocimiento informático - Computadora portátil - C Pregunta ¿Cómo obtener la ruta de una carpeta en una ruta conocida?

C Pregunta ¿Cómo obtener la ruta de una carpeta en una ruta conocida?

#include lt;stdio.hgt;

#include lt;errno.hgt;

#include lt;unistd.hgt;

#include lt;string .hgt;

# include lt;io.hgt;

# include lt;io.hgt;

#define MAX_FILE_PATH_LEN 128

#define INVALID_HANDLE -1

int main()

{

char aucFilePath[MAX_FILE_PATH_LEN 1] = {0}; char aucTempPath[MAX_FILE_PATH_LEN 1] = {0};

char *pFilePath = NULL

int iDirNum = 0

int iFileNum = 0; p>

p>

_finddata_t finddata = {0};

long findhandle = INVALID_HANDLE;

// Obtenga el directorio actual o use aucFilePath como entrada

pFilePath = getcwd(aucFilePath, MAX_FILE_PATH_LEN);

if (NULL == pFilePath)

{

printf("obtener el directorio de trabajo actual fallar, \n"

"errno = d, descripción del error: s\n", errno, strerror(errno));

getchar();

return -1;

}

printf("directorio de trabajo actual = s\n", aucFilePath);

strncpy(aucTempPath, aucFilePath, strlen( aucFilePath));

p>

strncat(aucTempPath, "\\*", MAX_FILE _PATH_LEN

findhandle = _findfirst(aucTempPath, & finddata); >

si (findhandle! = INVALID_HANDLE)

{

hacer {

if(finddata.attrib amp; _A_SUBDIR)

{

if ((0! = strcmp(finddata.name, ".")) amp; amp; (0! = strcmp(finddata.name, "...")))))

{

//número de subdirectorios

iDirNum;

printf("nombre del subdirectorio

e = s, ruta = s\\s, iDirNum = d\n",

finddata.name, aucFilePath, finddata.name, iDirNum);

}

}

else

{

//Número de subarchivos

iFileNum;

printf("archivo = s, iFileNum = d\n", finddata.name, iFileNum

}

} while(0 == _findnext); (findhandle, & finddata));

_findclose(findhandle) )

}

getchar();

return 0;

}