| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1262 人关注过本帖
标题:刚学C语言老师让我们把代码注释起来结果发过来没看懂
取消只看楼主 加入收藏
叫什么好捏
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2021-4-22
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
刚学C语言老师让我们把代码注释起来结果发过来没看懂
#ifdef _UNICODE
#undef _UNICODE
#endif // _UNICODE

#ifdef UNICODE
#undef UNICODE
#endif // _UNICODE

#include<Windows.h>
#include<stdio.h>
#include<string.h>



#define ONE 1
#define BUFSIZE 1024

     
int ListDirectoryContents( const char *path );



int main()
{
   
    char path[BUFSIZE] = "D:\\data\\exam\\1";   
   
    ListDirectoryContents( path );
   
   //结束
    return 0;
}


   
int ListDirectoryContents( const char *path )
{
   
    WIN32_FIND_DATA fileData = { 0 };
    HANDLE h = NULL;
    int exit = 0;
    char newPath[BUFSIZE] = {0};
    char *addressOfLastCharacter = NULL;

    //字符串格式化
    sprintf( newPath, "%s\\*.*", path );

    while(ONE)
    {
        
        if( ( h = FindFirstFile( newPath, &fileData ) ) == INVALID_HANDLE_VALUE )
        {
            printf( "Path not found: [%s]\n", path );   
            exit = 1;
            break;
        }
        do
        {
            
            if( ( strcmp( fileData.cFileName, ".") != 0 ) && ( strcmp( fileData.cFileName, ".." ) != 0 ) )
            {
                sprintf( newPath, "%s\\%s", path, fileData.cFileName );

            
                if( ( fileData.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY) != 0 )
                {
                    ListDirectoryContents( newPath );
                }
                else
                {                    
                    printf( "%s\n", fileData.cFileName );
                }
            }
        }        
        while( FindNextFile( h, &fileData ) );
   
        break;
        
    }
   
    FindClose( h );
   
    return exit;
搜索更多相关主题的帖子: exit path int 老师 char 
2021-04-22 14:48
快速回复:刚学C语言老师让我们把代码注释起来结果发过来没看懂
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015651 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved