Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>AFAIK this is what you intend:</p> <pre><code>struct stu { char **argv; // *argv[] will give you "error: flexible array member not at end of struct" int a; }; struct stu Stu; // Allocate Stu as a global stu struct fun(int argc, char * argv[]) {} int main() { char input[128]; char *argies[2]; // Static allocation of space for argv to point to struct stu *ptr = &amp;Stu; ptr-&gt;argv = argies; // You need to assign argv to point to allocated space ptr-&gt;argv[0] = "name"; ptr-&gt;argv[1] = input; fun(2, ptr-&gt;argv); // is 2nd argument we passing member of array argv?? } </code></pre> <p>If you do not declare an actual stu struct, then ptr wiill be initialized to <a href="https://stackoverflow.com/questions/1597405/what-happens-to-a-declared-uninitialized-variable-in-c-does-it-have-a-value">zero</a>. Also if you do declare a static struct stu (Stu above) but do not initialize the argv pointer, the argv pointer will be initialized to zero. Not pointing to "who knows where" but pointing to a very specific place.</p> <p>Note that input is not NULL terminated, in fact it is not initialized, so the variable name "argv" might be misleading because most programmers might assume that any char **argv holds NULL terminated C strings. Also, you probably want to dimension argies to 3 and put a NULL in the third position.</p> <p>You can pass ptr->argv[0] (the string "name") as *(ptr->argv), but the fun prototype would have to be fun(int argc, char * argv).</p> <p>**ptr->argv is a char.</p> <p>*ptr is a struct stu.</p> <p>**ptr is an error.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload