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 8371617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:12:24+00:00 2026-06-09T14:12:24+00:00

In C, is it possible to have a struct nested within another struct? How

  • 0

In C, is it possible to have a struct nested within another struct? How would I access the fields of the inner struct? Take the struct for kinfo_proc for example:

struct kinfo_proc {
  struct  extern_proc kp_proc;      /* proc structure */
  struct  eproc {
    struct  proc *e_paddr;    /* address of proc */
    struct  session *e_sess;  /* session pointer */
    struct  _pcred e_pcred;   /* process credentials */
    struct  _ucred e_ucred;   /* current credentials */
    struct   vmspace e_vm;    /* address space */
    pid_t e_ppid;     /* parent process id */
    pid_t e_pgid;     /* process group id */
    short e_jobc;     /* job control counter */
    dev_t e_tdev;     /* controlling tty dev */
    pid_t e_tpgid;    /* tty process group id */
    struct  session *e_tsess; /* tty session pointer */
#define WMESGLEN  7
    char  e_wmesg[WMESGLEN+1];  /* wchan message */
    segsz_t e_xsize;    /* text size */
    short e_xrssize;    /* text rss */
    short e_xccount;    /* text references */
    short e_xswrss;
    int32_t e_flag;
#define EPROC_CTTY  0x01  /* controlling tty vnode active */
#define EPROC_SLEADER 0x02  /* session leader */
#define COMAPT_MAXLOGNAME 12
    char  e_login[COMAPT_MAXLOGNAME]; /* short setlogin() name */
#if CONFIG_LCTX
    pid_t e_lcid;
    int32_t e_spare[3];
#else
    int32_t e_spare[4];
#endif
  } kp_eproc;
};

How would I go about trying to get the e_ppid of a newly made kinfo_proc instance?

  • 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-09T14:12:25+00:00Added an answer on June 9, 2026 at 2:12 pm

    You would be creating something like :

    struct kinfo_proc test1;
    test1.kp_eproc.e_ppid /// Access it like this.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to have a C++ template function which can access different fields
Is it possible to have multiple backend user group access lists in Typo3? For
Possible Duplicate: Operator overloading in C If I have a struct: typedef struct myStruct
Is it possible to concatenate variable names in C? Specifically, I have a struct
Is it possible to have mutual recursive types ( [<Struct>] ) spread across different
I have a third-party library (Mogre), in which is a struct (Vector3). I would
Is it possible in C# to have a Struct with a member variable which
Is it possible to have a class inheriting from a struct? More specifically, how
I have some struct containig a bitfield, which may vary in size. Example: struct
In particular, would it be possible to have code similar to this c++ code

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.