Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:58:01+00:00 2026-06-02T14:58:01+00:00

In order to get an environment variable in a C program, one could use

  • 0

In order to get an environment variable in a C program, one could use the following:

  • getenv()
  • extern char **environ;

But other than the above mentioned, is using char *envp[] as a third argument to main() to get the environment variables considered part of the standard?

#include <stdio.h>

int main(int argc, char *argv[], char *envp[])
{
    while(*envp)
        printf("%s\n",*envp++);
}

Is char *envp[] portable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:58:02+00:00Added an answer on June 2, 2026 at 2:58 pm

    The function getenv is the only one specified by the C standard. The function putenv, and the extern environ are POSIX-specific.

    EDIT

    The main parameter envp is not specified by POSIX but is widely supported.

    An alternative method of accessing the environment list is to declare
    a third argument to the main() function:

    int main(int argc, char *argv[], char *envp[])
    

    This argument can then be treated in the same way as environ, with the
    difference that its scope is local to main(). Although this feature is
    widely implemented on UNIX systems, its use should be avoided since,
    in addition to the scope limitation, it is not specified in SUSv3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In order to get my setup a bit closer to one click deployment, I
In order to get the next element in the list one just needs to
When I launch eclipse, i immediately get the following error: A Java Runtime Environment
I'm trying to get a website working on my test environment, but somehow it
In order to get better SEO and cleaner URLs, I tend to export certain
How to fix this regex in order to get the mentioned outcome ? regex:
I'm using System.Xml in order to get data from xml data: string test =
In cake php is how we can get order of query result according to
On Solaris, in order to get the msg_control field in struct msghdr and have
What's the best way to write an application in order to get it working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.