zoukankan      html  css  js  c++  java
  • 获得文件路径 _pgmptr, _makepath, _splitpath

    #include <stdlib.h>

    #include <stdio.h>

    int main(void)

    {

        char path_buffer[_MAX_PATH];

        char drive[_MAX_DRIVE];

        char dir[_MAX_DIR];

        char fname[_MAX_FNAME];

        char ext[_MAX_EXT];

        _makepath(path_buffer, "c", "\sample\myprogarm\","makepath", "txt" ); // C4996

        printf( "Path created with _makepath: %s ", path_buffer );

        _splitpath( path_buffer, drive, dir, fname, ext ); // C4996

        printf("Path extracted with _splitpath: ");

        printf("Drive: %s ", drive );

        printf("Dir: %s ", dir );

        printf("Filename: %s ", fname );

        printf("Ext: %s ", ext );

        return 1;

    }

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

    int main(int argc, char * argv[])
    {
        char s[10] = {0};

        int strLen = strlen(_pgmptr);

        if (sizeof(s)/sizeof(s[0]) < strLen)
        {
            strLen = sizeof(s)/sizeof(s[0]);
        }

        memcpy(s, _pgmptr, strLen);

        s[sizeof(s)/sizeof(s[0])] = '';

        printf(" s=%s ", s);

        system("pause");
        return 0;
    }

  • 相关阅读:
    省选模拟81
    概率期望+计数
    省选模拟80
    省选模拟79
    省选模拟78
    Jenkins 安装及 Git | Maven 安装
    虚拟机VirtualBox及轻量级的CentOS
    服务器免密码登录
    Nginx 常用配置模板
    IDEA配置 及 快捷键
  • 原文地址:https://www.cnblogs.com/pswzone/p/3221004.html
Copyright © 2011-2022 走看看