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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:17:48+00:00 2026-06-01T23:17:48+00:00

Basically, I have an array of char* that I want to pass and modify

  • 0

Basically, I have an array of char* that I want to pass and modify in this function, so I pass in a pointer to an array of char*. That is, I want to pass a pointer to char* arr[]. What is the difference between the two?

  • 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-01T23:17:49+00:00Added an answer on June 1, 2026 at 11:17 pm

    As always, http://cdecl.org is your friend:

    • char * (*arr)[] – “declare arr as pointer to array of pointer to char”
    • char *** arr – “declare arr as pointer to pointer to pointer to char”

    These are not the same. For a start, the first is an incomplete type (in order to use a pointer to an array, the compiler needs to know the array size).

    Your aim isn’t entirely clear. I’m guessing that really all you want to do is modify the underlying data in your array of char *. If so, then you can just pass a pointer to the first element:

    void my_func(char **pointers) { 
        pointers[3] = NULL;  // Modify an element in the array
    }
    
    char *array_of_pointers[10];
    
    // The following two lines are equivalent
    my_func(&array_of_pointers[0]);
    my_func(array_of_pointers);
    

    If you really want to pass a pointer to an array, then something like this would work:

    void my_func(char *(*ptr)[10]) {
        (*ptr)[3] = NULL;  // Modify an element in the array
    }
    
    char *array_of_pointers[10];
    
    // Note how this is different to either of the calls in the first example
    my_func(&array_of_pointers);
    

    For more info on the important difference between arrays and pointers, see the dedicated chapter of the C FAQ: http://c-faq.com/aryptr/index.html.

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

Sidebar

Related Questions

I have a pretty simple problem. Basically I have an array called $list that
I am learning about arrays, and basically I have an array that collects a
Basically I have this string $str=word1 word2 word3; I need array( 'word1', 'word2', 'word3'
Basically, I have an array like this: val base_length = Array( 0, 1, 2,
So, basically I have an NSArray . I want to get an array with
I have a 2-dimensional array of objects and I basically want to databind each
I have a large multidimensional array and I basically want to drop the first
I have a template function in C++ that basically writes values to an XML
I have a C code that creates an array of char pointers as the
So I basically have a vector args with 1 argument per array that I'm

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.