请大神帮忙看下,问题出在哪了?读取目录下文件内容,怎么调也不对,快疯了
程序代码如下:程序代码:
#include <stdio.h> #include <uf.h> #include <uf_defs.h> #include <uf_exit.h> #include <uf_ui.h> #include <uf_styler.h> #include <uf_mb.h> #include "section.h" #include <io.h> #include <uf_ui_types.h> #include <stdarg.h> //#include <fstream> //using namespace std; static void do_api ( int dialog_id) { int i; double quantity,height,h_calc; char msg[256+1],path[200],cout,line[1024],*p,*buf; struct _finddata_t findData; intptr_t handle; long lfDir; FILE *fp; int file_size; char *tmp; UF_UI_open_listing_window(); get_real_data( dialog_id,SECTION_QUANTITY,&quantity ); get_real_data( dialog_id,SECTION_HEIGHT,&height ); get_string_data( dialog_id,SECTION_PATH,&path ); h_calc=height/(quantity-1); strcat(path, "\\*.*"); ///* 用于测试 //UF_UI_open_listing_window(); //sprintf(msg,"%s \n",path); //UF_UI_write_listing_window(msg); /////* 用于测试 //UF_UI_open_listing_window(); //sprintf(msg,"quantity=%f ,height=%f ,section height=%f \n",quantity,height,h_calc); //UF_UI_write_listing_window(msg); handle = _findfirst(path, &findData); if((lfDir = _findfirst(path,&findData))==-1l) { for(i=1;i<20;i++) ECHO("No file is found\n"); } else { sprintf(msg,"file list:\n"); UF_UI_write_listing_window(msg); } do{ if(strcmp(findData.name, ".") != 0 && strcmp(findData.name, "..") != 0) { sprintf(msg,"%s \n",findData.name); UF_UI_write_listing_window(msg); fp = fopen(findData.name,"r"); fseek( fp , 0 , SEEK_END ); file_size = ftell( fp ); fseek( fp , 0 , SEEK_SET); tmp = (char *)malloc( file_size * sizeof( char ) ); fread( tmp , file_size , sizeof(char) , fp); sprintf(msg,"%s \n",tmp); UF_UI_write_listing_window(msg); buf=(char*)malloc(1024*sizeof(char)); while(1) { p=fgets(buf, 1024, fp); sprintf(msg,"%s \n",buf); UF_UI_write_listing_window(msg); if(!p) break; } fclose(fp); } }while( _findnext( lfDir, &findData ) == 0 ); _findclose(handle); UF_terminate (); return (UF_UI_CB_EXIT_DIALOG); }
这个在UG中做的开发,用的C编程,编译不报错,但是就是不出结果,输出完文件名就没了,请大神帮忙看看