c语言(turbo c)
c语言中什么函数能对文件夹进行操作?
在C中,使用findfirst和findnext两个函数就可以遍历目录了,例如:structffblkFFileStru;intiValue;iValue=findfirst("c:\\test\\*。*",FFileStru,0);//0表示寻找所有文件和目录while(iValue){。
。。。。。。。。。。//这里是处理语句,有关文件的信息保存在结构变量FFileStru里iValue=findnext(FFileStru);}findfirst的第三个参数可以具有下列值:#defineFA_RDONLY0x01/*Readonlyattribute*/#defineFA_HIDDEN0x02/*Hiddenfile*/#defineFA_SYSTEM0x04/*Systemfile*/#defineFA_LABEL0x08/*Volumelabel*/#defineFA_DIREC0x10/*Directory*/#defineFA_ARCH0x20/*Archive*/遍历一个文件夹可以仿照以上代码写个递归就OK了。
新建文件,就是用FILI读取一个文件,如果文件不存在就#includeFILE*fopen("ugg。txt","w");创建一个ugg。txt文件mkdir("ugg");//创建一个目录rmdir("ugg");//删除一个目录,并且目录不能为空--------------------------------------------------------我写的几个实例,看不懂问我---------------------------------------------------------1。
fopenSyntax:#includeFILE*fopen(constchar*fname,constchar*mode);Thefopen()functionopensafileindicatedbyfnameandreturnsastreamassociatedwiththatfile。
Ifthereisanerror,fopen()returnsNULL。modeisusedtodeterminehowthefilewillbetreated(i。e。forinput,output,etc)ModeMeaning"r"Openatextfileforreading"w"Createatextfileforwriting"a"Appendtoatextfile"rb"Openabinaryfileforreading"wb"Createabinaryfileforwriting"ab"Appendtoabinaryfile"r+"Openatextfileforread/write"w+"Createatextfileforread/write"a+"Openatextfileforread/write"rb+"Openabinaryfileforread/write"wb+"Createabinaryfileforread/write"ab+"Openabinaryfileforread/write *input=fopen("stuff","r");ch=getc(input);-*********************************************************2。
#include#include#includeusingnamespacestd;voidfilesearch(stringpath,intlayer){struct_finddata_tfilefind;stringcurr=path+"\\*。
*";intdone=0,i,handle;if((handle=_findfirst(curr。c_str(),&filefind))==-1)return;while(!(done=_findnext(handle,&filefind))){if(strcmp(filefind。
name,"。。"))//不返回{if((_A_SUBDIR==filefind。attrib)){for(i=0;i>path;filesearch(path,0);system("PAUSE");return0;}。
答:按alt+f5就可以了。。不知路径有没有弄错。。如果你的路径不对,你可以改一下。首先运行TC目录下的TC.exe,这是TC2.0编译环境的主程序,按F10键打开...详情>>