请大家帮帮忙!

litaiming 2014-05-06 05:12:15
我有个任务,想用c实现,请大家帮帮忙(我是c菜鸟,常用dev-c):系统盘中有个文件夹下有n(n>1000)个文件,文件名为wj+xxxxx.txt(xxx是数字),文件大小不一样m(m>1000).我想用c读字节,首先:1)怎样在c中知道n是多少? m怎样求?
2)怎样在可变的文件名中用程序自动读?
构想用循环数做字符串代替文件名做循环,不知怎样做请大家帮忙!!!!我想用别的方式报答!
...全文
101 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
litaiming 2014-05-06
  • 打赏
  • 举报
回复
刚才那句话是:擅用
litaiming 2014-05-06
  • 打赏
  • 举报
回复
谢谢:zhao4zhong1大师!善用系统语言.
赵4老师 2014-05-06
  • 打赏
  • 举报
回复
_fstat, _fstati64 Get information about an open file. int _fstat( int handle, struct _stat *buffer ); __int64 _fstati64( int handle, struct _stat *buffer ); Function Required Header Compatibility _fstat <sys/stat.h> and <sys/types.h> Win 95, Win NT _fstati64 <sys/stat.h> and <sys/types.h> Win 95, Win NT For additional compatibility information, see Compatibility in the Introduction. Libraries LIBC.LIB Single thread static library, retail version LIBCMT.LIB Multithread static library, retail version MSVCRT.LIB Import library for MSVCRT.DLL, retail version Return Value _fstat and _fstati64 return 0 if the file-status information is obtained. A return value of –1 indicates an error, in which case errno is set to EBADF, indicating an invalid file handle. Parameters handle Handle of open file buffer Pointer to structure to store results Remarks The _fstat function obtains information about the open file associated with handle and stores it in the structure pointed to by buffer. The _stat structure, defined in SYS\STAT.H, contains the following fields: st_atime Time of last file access. st_ctime Time of creation of file. st_dev If a device, handle; otherwise 0. st_mode Bit mask for file-mode information. The _S_IFCHR bit is set if handle refers to a device. The _S_IFREG bit is set if handle refers to an ordinary file. The read/write bits are set according to the file’s permission mode. _S_IFCHR and other constants are defined in SYS\STAT.H. st_mtime Time of last modification of file. st_nlink Always 1 on non-NTFS file systems. st_rdev If a device, handle; otherwise 0. st_size Size of the file in bytes. If handle refers to a device, the st_atime, st_ctime, and st_mtime and st_size fields are not meaningful. Because STAT.H uses the _dev_t type, which is defined in TYPES.H, you must include TYPES.H before STAT.H in your code. Example /* FSTAT.C: This program uses _fstat to report * the size of a file named F_STAT.OUT. */ #include <io.h> #include <fcntl.h> #include <time.h> #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void main( void ) { struct _stat buf; int fh, result; char buffer[] = "A line to output"; if( (fh = _open( "f_stat.out", _O_CREAT | _O_WRONLY | _O_TRUNC )) == -1 ) _write( fh, buffer, strlen( buffer ) ); /* Get data associated with "fh": */ result = _fstat( fh, &buf ); /* Check if statistics are valid: */ if( result != 0 ) printf( "Bad file handle\n" ); else { printf( "File size : %ld\n", buf.st_size ); printf( "Time modified : %s", ctime( &buf.st_ctime ) ); } _close( fh ); } Output File size : 0 Time modified : Tue Mar 21 15:23:08 1995 File Handling Routines See Also _access, _chmod, _filelength, _stat
赵4老师 2014-05-06
  • 打赏
  • 举报
回复
system("dir /b /a-d c:\\*.* >d:\\allfiles.txt"); //读文件d:\\allfiles.txt的内容即C:\\下所有文件的名字 system("dir /b /a-d /s c:\\*.* >d:\\allfilesinsub.txt"); //读文件d:\\allfilesinsub.txt的内容即C:\\下所有文件的名字包含子目录 system("dir /b /ad c:\\*.* >d:\\alldirs.txt"); //读文件d:\\alldirs.txt的内容即C:\\下所有子目录的名字 请记住,能用shell命令获取文件、文件夹信息或者操作文件、文件夹最好用shell命令获取或者操作,而不要用各种API获取或者操作,因为当遇到非法文件夹名或非法文件名或非法文件长度、非法文件日期、压缩文件、链接文件、稀疏文件……等各种意料之外的情况时,API会处理的不全面或陷入死循环,而shell命令不会。
【特征工程是什么?】 身高不同的两人,比较体重毫无意义, 但是如果将身高体重加以计算,转化成了BMI指数:BMI=体重/(身高^2) 通过比较这个新创造的特征值,谁胖谁瘦就一目了然了。 这就是特征工程,将原始数据转换为可以更好的、代表预测模型潜在问题的特征,通过分析这个新的特征,可以得到更准确的预测结果。 【特征工程——Python数据分析必备】 脏数据的“清洗剂” 有人说:学会了Python语言,就会做数据分析? 不一定! 你拿到的数据样本集,有可能存在这些问题: 如果样本数据存在问题,对数据建模的执行效率会有很大影响,甚至可能会造成模型结果的偏差。 不懂特征工程,数据分析=白忙一场! 【站内首门!特征工程全解课程】 过去,数字化是企业优化的要点; 而今,数字化成为了企业活下去的关键。 而数据分析应用有多广,特征工程的学习需求就有多大。 不过,大部分课本对于特征工程这一知识点鲜有提及,市面上的课程也少之又少,导致很多人在实际工作或学习中,遇到问题束手无策,严重降低效率。 CSDN全站首发——Python数据处理与特征工程 课程聚焦数据科学中,数据清洗与分析前的特征提取过程,解决数据科学中最重要的原始数据清洗和特征提取。 【定制课程 精准扫除学习盲点】 课程充分考虑各类实际问题,将每个知识点融入到对应的代码实例中,初学者也可无压力上手,讲师手把手带领入门。 知识点扫盲 + 案例实践 + 线上答疑 扫清数据分析前的所有障碍,提升你的数据工作的效率与准确度。 如果你是: 在这里你可以收获...... 了解如何将各类型数据载入计算机,进而愉快的探索数据科学; 掌握如何将需要分析的数据转化为算法模型可以接受的格式; 学会特征提取最基本的处理方式,为后续的算法学习打好基础。 经过19节课程的学习,你可以基本掌握数据采集、读取以及清洗的方法,具备进一步学习数据分析乃至深度学习的能力,能够大大拓宽你日后的求职道路。 【三重福利  惊喜等你】

69,381

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧