#include <io.h>#include <stdio.h>#include <iostream>using namespace std;int ReadStationID(char(*id)[50]){ struct _finddata_t c_file; long hFile; char *p = NULL; int i = 0; /* Find first .c file in current directory */ if ((hFile = _findfirst("E:\\KJ_WORKDIR\\usr\\callsc_mtv\\zjcfgmn\\Station\\*.txt", &c_file)) == -1L) { printf("No *.txt files in current directory!\n"); return -1; } if (c_file.name) sprintf(id[i++], "%s", strtok(c_file.name, ".")); while (_findnext(hFile, &c_file) == 0) { sprintf(id[i++], "%s", strtok(c_file.name, ".")); //printf(" %s\n", c_file.name); } _findclose(hFile); return 0;}int main(){ char id[50][50] = {0}; ReadStationID(id); for(int i = 0; i< 50; i++) { cout << id[i] << endl; }}
转载于:https://www.cnblogs.com/xpylovely/p/11586474.html