• [C语言] 获得 pwd 的几种函数


    _getcwd()

    GetCurrentDirectory

    GetModuleFileName

    main函数参数 argv[0]

    // crt_getcwd.c
    // This program places the name of the current directory in the
    // buffer array, then displays the name of the current directory
    // on the screen. Passing NULL as the buffer forces getcwd to allocate
    // memory for the path, which allows the code to support file paths
    // longer than _MAX_PATH, which are supported by NTFS.
    
    #include <direct.h>
    #include <stdlib.h>
    #include <stdio.h>
    
    int main( void )
    {
       char* buffer;
    
       // Get the current working directory:
       if( (buffer = _getcwd( NULL, 0 )) == NULL )
          perror( "_getcwd error" );
       else
       {
          printf( "%s 
    Length: %d
    ", buffer, strnlen(buffer) );
          free(buffer);
       }
    }
  • 相关阅读:
    项目总结
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    浅谈Vue与swiper轮播图框架结合小案例
  • 原文地址:https://www.cnblogs.com/liujx2019/p/11189020.html
Copyright © 2020-2023  润新知