首页 > 其他分享 >文件IO-chdir-getcwd

文件IO-chdir-getcwd

时间:2022-08-23 03:01:03浏览次数:150  
标签:chdir int getcwd char IO path include buf

getcwd

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define MAX 512

int main(int argc, char * argv[])
{
    // 方法一
    char path[MAX];
    path[0] = '\0';
    getcwd(path, sizeof(path));
    puts(path);

    // 方法二
    char * buf = NULL;
    buf = getcwd(NULL, 0);
    puts(buf);
    free(buf);

    exit(EXIT_SUCCESS);
}

标签:chdir,int,getcwd,char,IO,path,include,buf
From: https://www.cnblogs.com/starc/p/16614795.html

相关文章

  • JavaIO流
    JavaFile类的功能非常强大,利用java基本上可以对文件进行所有操作。我们看看源码/***Internalconstructorforalready-normalizedpathnamestrings.*......
  • IO流
    IO流流的分类按操作数据不同,分为字节流和字符流。按数据流的流向分为输出流和输入流。按流的角色分为节点流和包装流。抽象基类字节流字符流输入流Input......
  • React报错之React Hook 'useEffect' is called in function
    正文从这开始~总览为了解决错误"ReactHook'useEffect'iscalledinfunctionthatisneitheraReactfunctioncomponentnoracustomReactHookfunction",可以将......
  • ssh 报错hibernate java.lang.ClassCastException: [Ljava.lang.Object; cannot be ca
    ssh报错hibernatejava.lang.ClassCastException:[Ljava.lang.Object;cannotbecasttoXXX这个应该说是hibernate报错:hibernatejava.lang.ClassCastException:[L......
  • 网络编程篇:进程、线程、协程、IO模型补充学习
    目录一、进程、线程、协程二、阻塞与非阻塞三、IO多路复用四、并发并行,同步异步,阻塞非阻塞一、进程、线程、协程#进程:进程就是一个程序在内存中的运行,进程是资源分配的......
  • When to use Include in EF? Not needed in projection?
    WhentouseIncludeinEF?Notneededinprojection?IhavethefollowinginEntityFrameworkCore:publicclassBook{publicInt32Id{get;set;}publ......
  • _I _O _IO
    #define  _I   volatitileconst   /*!<Defines'readonly'permissions  定义只读权限 */所以_I修饰的变量只用来读取,且该变量不可以被编译器优化......
  • [VSCode] REST Client Extension
    InVSCode,installRESTClinetExtension:CreateAPI_EXAMPLE.httpfileinrootfolder:###GetmockGEThttp://localhost:3000/dataHTTP/1.1###Postmock......
  • VSDX Annotator for mac(Visio 绘图工具)
    Visio绘图的工具哪款好用?推荐使用VSDXAnnotatorMac版,一款用于在Mac上操作MSVisio绘图的工具。它提供了广泛的注释可能性,以及在多平台环境中共享可视文档。详情:VSD......
  • *Codeforces Round #363 (Div. 1) A. Vacations(状态机)
    https://codeforces.com/contest/698/problem/AVasya有n天假期!Vasya知道关于这n天中每一天的以下信息:那家健身房是否开门,以及那天是否在互联网中进行了比赛。第i天有四个......