如何在C程序中使用环境变量 [英] How to use environment variable in a C program
问题描述
我需要知道一种在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屋!