标题:刚学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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-505536-1-1.html




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

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