如何在C程序中使用环境变量 [英] How to use environment variable in a C program

查看:142
本文介绍了如何在C程序中使用环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道一种在C编程语言中使用环境变量的方法.如何使用和阅读它们?

I need to know a way for use environment variables in the C programming language. How can I use and read them?

例如,读取环境变量或获取环境变量的值并将其加载到另一个变量中.

For example, read an environment variable or take the value of an environment variable and load it in another variable.

推荐答案

您可以使用以下功能-

char * getenv (const char *name)-返回一个字符串,它是环境变量名称的值.

char * getenv (const char *name)-returns a string that is the value of the environment variable name.

char * secure_getenv (const char *name)

在此处了解更多功能- http ://www.gnu.org/software/libc/manual/html_node/Environment-Access.html#Environment-Access

Read about some more functions here -http://www.gnu.org/software/libc/manual/html_node/Environment-Access.html#Environment-Access

这篇关于如何在C程序中使用环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆