讀取目錄下的檔案名稱

Home Home
引用 | 編輯 johnroyer
2006-03-08 21:05
樓主
推文 x0
小弟自己用 strtok()
寫了一個可以讀取檔案名稱
且會忽略資料夾名稱的程式

環境:Windows XP
編譯器:Dev-C++ 4.9.9

程式碼:
#include <stdio.h>
#include <stdlib.h>

// strtok(), strtok_r()

int main()
{
FILE *cmd;
FILE *pt;
char **in,tmp;
char *ch_pt;
char str;
char str2;
char *str_chk;
int c_num=10,cnt=0;
int a,b,c,d;

in = (char**)malloc( sizeof(char*) * c_num );
for(a=0;a<c_num;a++) in=(char*)malloc( sizeof(char) * 260 );
//---------------------------------------------
system("dir /o:n >> log.tmp");
cmd = fopen("log.tmp","r");
a=0;
while( !feof(cmd) )
{
tmp = fgetc(cmd);
if( tmp=='\n' )
{
in='\0'
if( cnt+1 >= c_num )
{
in = (char**)realloc(i ..

訪客只能看到部份內容,免費 加入會員



獻花 x0