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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:51:55+00:00 2026-06-12T17:51:55+00:00

Possible Duplicate: How do I use arrays in C++? I have the following C

  • 0

Possible Duplicate:
How do I use arrays in C++?

I have the following C code:

int main () {
    char *pathvc[MAX_PATHS];
    parsePath(pathvc);

    struct command_t command;

    command.name = lookup(command.argv, pathvc); //command.argv is: char *argv[MAX_ARGS];
}

char* lookupPath(char **argv, char **dir) {
    //Some implementation
}

This is the debug information that I am getting in the main function:

Name : pathvc Details:{0x804c208 “/usr/lib/lightdm/lightdm”,
0x804c221 “/usr/local/sbin”, 0x804c231 “/usr/local/bin”, 0x804c240
“/usr/sbin”, 0x804c24a “/usr/bin”, 0x804c253 “/sbin”, 0x804c259
“/bin”, 0x804c25e “/usr/games”, 0x0 }
Default:0xbffff0a8 Decimal:3221221544 Hex:0xbffff0a8
Binary:10111111111111111111000010101000 Octal:027777770250

Name : pathvc[0] Details:0x804c208 “/usr/lib/lightdm/lightdm”

Name : pathvc[1] Details:0x804c221 “/usr/local/sbin”

Name : pathvc[2] Details:0x804c231 “/usr/local/bin”

Name : pathvc[3] Details:0x804c240 “/usr/sbin”

Name : pathvc[4] Details:0x804c24a “/usr/bin”

Name : pathvc[5] Details:0x804c253 “/sbin”

Name : pathvc[6] Details:0x804c259 “/bin”

Name : pathvc[7] Details:0x804c25e “/usr/games”

However when I pass pathvc in the lookup function, I am getting this:

Name : dir Details:0xbffff0a8 Default:0xbffff0a8 Decimal:3221221544
Hex:0xbffff0a8 Binary:10111111111111111111000010101000
Octal:027777770250

Name : *dir Details:0x804c208 “/usr/lib/lightdm/lightdm”

Name : **dir Details:47 ‘/’

Why is it that I am passing an array of pointers to the lookup function which accepts it as a double pointer but it is only pointing to the first path instead of complete list of paths.

Pardon me if I am doing/asking a very silly question because I am not comfortable with pointers in C.

  • 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-12T17:51:57+00:00Added an answer on June 12, 2026 at 5:51 pm

    It’s just a matter of what the debugger knows. In the caller, the debugger can see that there are MAX_PATHS pointers. In the called function, it has no idea, so it doesn’t know how many entries to show you. If you manually asked it for the others, it would show them to you.

    It’s just like this:

    void someFunc(int *j)
    {
       // does j point to a single integer? An array? Who knows?
    }
    
    void foo(void)
    {
       int p = 3;
       int* j = &p;
       // here we know j points to one integer
       someFunc(j);
    }
    
    void foo2(void)
    {
       int* j[4];
       // here we know j is an array of four pointers
       someFunc(j);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do I use arrays in C++? I have no idea how
Possible Duplicate: !in_array use in PHP - conditional statments I have this code that
Possible Duplicate: I have an array of integers, how do I use each one
Possible Duplicate: How to use include within a function? i have two file inc.php
Possible Duplicate: Are C# arrays thread safe? I have been programming C# for 10
Possible Duplicate: Can someone Explain this jQuery code? I have posted this before, but
Possible Duplicate: Comparing Arrays in C# I have a two string arrays: string[] a;
Possible Duplicate: OutOfMemoryError: bitmap size exceeds VM budget :- Android I have code like
Possible Duplicate: Cannot use concatenation when declaring default class properties in PHP? The following
Possible Duplicate: Passing multidimensional arrays as function arguments in C I'm trying to use

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.