getenv.cpp

博客涉及C++和Linux相关信息技术内容,但具体信息缺失。C++是常用编程语言,Linux是广泛使用的操作系统,二者结合在后端开发等领域有诸多应用。
/*
 * function: 打印环境变量(修改或删除环境变量)
 * 
 * 2020-12-01
 */

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

int main(int argc, char *argv[])
{
    char *buf = NULL;

    buf = getenv("HOME");
    printf("HOME = %s\n", buf);

    buf = getenv("SHELL");
    printf("SHELL = %s\n", buf);

    buf = getenv("TERM");
    printf("TERM = %s\n", buf);

    setenv("TERM", "xterm", 1); 

    buf = getenv("TERM");
    printf("TERM = %s\n", buf);

    unsetenv("TERM");

    buf = getenv("TERM");
    printf("TERM = %s\n", buf);

    return 0;
}

getenv.cpp

* 正在执行任务: g++ -o C:\cpp_project/uninstall C:\cpp_project\uninstall.cpp -std=c++17 -Wall -Wextra -g C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ADMINI~1\AppData\Local\Temp\ccEOuuki.o: in function `ArduinoUninstaller::ArduinoUninstaller()': C:/cpp_project/uninstall.cpp:27:(.text$_ZN18ArduinoUninstallerC1Ev[_ZN18ArduinoUninstallerC1Ev]+0xd0): undefined reference to `__imp_CoTaskMemFree' C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/cpp_project/uninstall.cpp:31:(.text$_ZN18ArduinoUninstallerC1Ev[_ZN18ArduinoUninstallerC1Ev]+0x104): undefined reference to `__imp__dupenv_s' C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ADMINI~1\AppData\Local\Temp\ccEOuuki.o: in function `ArduinoUninstaller::deleteShortcuts()': C:/cpp_project/uninstall.cpp:254:(.text$_ZN18ArduinoUninstaller15deleteShortcutsEv[_ZN18ArduinoUninstaller15deleteShortcutsEv]+0xfe): undefined reference to `__imp_CoTaskMemFree' C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/cpp_project/uninstall.cpp:265:(.text$_ZN18ArduinoUninstaller15deleteShortcutsEv[_ZN18ArduinoUninstaller15deleteShortcutsEv]+0x1e0): undefined reference to `__imp_CoTaskMemFree' C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ADMINI~1\AppData\Local\Temp\ccEOuuki.o:uninstall.cpp:(.rdata$.refptr.FOLDERID_Desktop[.refptr.FOLDERID_Desktop]+0x0): undefined reference to `FOLDERID_Desktop' C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ADMINI~1\AppData\Local\Temp\ccEOuuki.o:uninstall.cpp:(.rdata$.refptr.FOLDERID_Programs[.refptr.FOLDERID_Programs]+0x0): undefined reference to `FOLDERID_Programs' C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ADMINI~1\AppData\Local\Temp\ccEOuuki.o:uninstall.cpp:(.rdata$.refptr.FOLDERID_LocalAppData[.refptr.FOLDERID_LocalAppData]+0x0): undefined reference to `FOLDERID_LocalAppData' collect2.exe: error: ld returned 1 exit status * 终端进程“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command g++ -o C:\cpp_project/uninstall C:\cpp_project\uninstall.cpp -std=c++17 -Wall -Wextra -g”已终止,退出代码: 1。 * 终端将被任务重用,按任意键关闭。
12-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值