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

  • Home
  • SEARCH
  • 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 9020241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:58:07+00:00 2026-06-16T04:58:07+00:00

could you please help me understand this. I have function that needs char ***argv

  • 0

could you please help me understand this.

I have function that needs “char ***argv“;

As far as I understand it’s :
pointer to pointer to array of char pointers.

something like this: “char *arr[]” ?

char xx1 = '1';
char xx2 = '2';
char *argv[] = {&xx1,&xx2};

Then I call my function with gtk_init (&argc, &argv);

And get error:

main.cpp:43:31: error: cannot convert ‘char* (*)[2]’ to ‘char***’ for argument ‘2’ to ‘void gtk_init(int*, char***)’

Thank you for any help.

  • 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-16T04:58:08+00:00Added an answer on June 16, 2026 at 4:58 am

    A char*** is a “pointer to pointer to pointer to char”. No arrays involved at all. Your argv is an “array of 2 pointer to char”. The name of your array, argv, will decay to a pointer to its first element in certain circumstances – this pointer will have type char**, or “pointer to pointer to char”.

    When you do &argv, you get a char* (*)[2], or a “pointer to array of 2 pointer to char”. Which is not what you want. That’s because you’re taking the address of an array, not of a pointer.

    Also, you’re going to have a problem with the fact that you’re pointers in argv are just pointing at single chars, not at null-terminated strings. gtk_init will almost certainly be expecting null-terminated strings.

    So what you can you do? Try this:

    char xx1[] = "1"; // Now these are null-terminated strings
    char xx2[] = "2";
    char* argv[] = {xx1, xx2};
    char** argvp = argv; // Use the fact that the array will decay
    gtk_init(&argc, &argv); // &argv will now be a char***
    

    The reason for using arrays for the strings is because we need the chars to be non-const, but a char* str = "hello"; style declaration is deprecated – it must be const char*. However, by using arrays, the contents of the string literal are copied into our array, so we can freely make it non-const.

    gtk_init really just expects you to pass the argc and argv parameters of your main function to it like so:

    int main(int argc, char* argv[])
    {
      gtk_init(&argc, &argv);
      // ...
    }
    

    You may now ask “But why is &argv now allowed? argv is the same type as in the question! Why don’t we get a pointer to array again?” Actually, argv is not the same type, despite how much it looks like it is. When you define a function that takes an array argument, it actually gets transformed to a pointer. So the definition of main is equivalent to:

    int main(int argc, char** argv);
    

    So when we do &argv, we’re totally fine, because it gives us a char***.

    As @OmnipotentEntity says in the comments – you’d better have a good excuse for not passing the parameters of main to gtk_init.

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

Sidebar

Related Questions

I have this regex: [\s\S-[<>]]* Could you please help me understand what does this
Please could someone help me understand why the div.fl element shown in Developer Tools
Could you please help me converting this c++ code into python: I am trying
Could someone please help me to convert this String into a Map ... String
Could somebody please help me get Clang up and running? (I don't have 3.2)
Could someone please help explain why I can't get this to work? I properly
I was wondering if someone could help me understand this problem. I prepared a
Could someone here please help me understand how to determine when floating point limitations
Could someone please help me to understand why the following block of code keeps
Could someone please help me understand what the link tags are used for within

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.