网站首页 > 文章中心 > 其它

c语言查找文件的函数

作者:小编 更新时间:2023-09-22 11:18:19 浏览量:224人看过

VC环境中用C语言查找当前路径下的所有文件和文件夹的函数是什么?

void FileList(sockaddr_in sour_addr,char strStartDir[])

{

sockaddr_in destaddr;

int sourlen = 0;

int ret = 0;

int len = 0;

int flen = 0;

fd_set fdr;

unsigned short blocknum = 0;

FILE *file;

strcat(filename,"\\*");

destaddr.sin_family = AF_INET;

destaddr.sin_port = sour_addr.sin_port;

destaddr.sin_addr.s_addr = inet_addr(desthost);//

HANDLE hFind;

hFind = FindFirstFile(filename, FindFileData);

if (hFind == INVALID_HANDLE_VALUE)

printf ("Invalid File Handle");

}

else

while(FindNextFile(hFind,FindFileData))

printf(FindFileData.cFileName);

printf("\r\n");

len = filldata(blocknum++,FindFileData.cFileName,strlen(FindFileData.cFileName),sendbuffer,sizeof(sendbuffer));

ret = sendto(serverSock,sendbuffer,len,0,(sockaddr *)destaddr,sizeof(destaddr));

FindClose(hFind);

return;

C语言中文本文件定位用什么函数

c语言的文件定位是fseek函数fseek(文件指针,位偏移,起始点);起始点c提供了文件开始

文件当前位置

文件末尾三个值分别对应0

例:fseek(fp,100L,0);将位置指针移到离文件头100个字节处

如果第二个参数是负数的就是后退多少字节

c语言findfirst函数如何搜索无后缀文件

函数名: findfirst(); findnext ();功 能: 搜索磁盘目录; 取得下一个匹配的findfirst模式的文件 ;用 法: int findfirst(char *pathname, struct ffblk *ffblk, int attrib); int findnext(struct ffblk *ffblk); 举例: /* findnext example */ #include #include int main(void) { struct ffblk ffblk; int done; printf("Directory listing of *.*\n"); done = findfirst("*.*",ffblk,0); while (!done) { printf(" %s\n", ffblk.ff_name); done = findnext(ffblk); }

c语言字符串的查找用什么函数

用strstr这个函数

包含文件:string.h

函数名: strstr

返回值:返回该位置的指针,如找不到,返回空指针.

C语言查找函数

首先,指针默认只有一个地址的长度的空间,存不了那么多的字符.

其次,传值和传地址一塌糊涂,完全就是乱写么.

scanf的第二个参数是地址,如果本身不是指针则需要取址符.

我给你重写了算了

#includestdio.h

int Retrieve(int array[],int length,int x);/*形参x直接传值就可以了*/

int main()

int *a,x;

int length,i;

scanf("%d",length);

a = (int)malloc(sizeof(int)*length); /*申请一个内存空间用来存放数据,或者直接用一个大数组也可以*/

以上就是土嘎嘎小编为大家整理的c语言查找文件的函数相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章