C系统(“echo $ HOME”);想要$ HOME指向的东西

问题描述 投票:-6回答:1

用C编程:想在系统命令中使用特殊字符。 system(“echo $ HOME”);想要$ HOME系统变量而不是文字$ HOME。谢谢,基思

c# system
1个回答
0
投票
#include <stdio.h>  // for printf()
#include <stdlib.h> // for getenv()
int main()
{
    char *home;
    home = getenv("HOME");
    printf("Value is = %s\n", home);
}
© www.soinside.com 2019 - 2024. All rights reserved.