Passing a pointer to a char array as an argument to a function - C

macalaca

In the following function declaration, the first argument is a String, specifically, an array of chars, and the third argument is a pointer to an integer. Is the second argument a pointer to an array of chars? In other words, a pointer to a pointer? I find this after reading this answer to a related question: Difference between passing array and array pointer into function in C

void setup(char inputBuffer[], char *args[], int *background) {...}

In other words, is *args[] equivalent to **args?

Thanks a lot!

musarithmia

Yes, in passing arguments to a function, char *args[] is equivalent to char **args.

In the first argument, char inputBuffer[], the function actually receives not the whole char array but only a pointer variable holding the address of its first element.

In the second argument, char *args[], similarly, the function receives not the whole array of pointers to chars, but a pointer variable holding the address of the first element. In this case the element is itself a pointer. Therefore the function receives a pointer to a char pointer, equivalent to char **args.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Passing a pointer to a char array as an argument to a function - C

From Dev

Passing char pointer as argument to function

From Dev

Passing a char pointer array to a function

From Dev

Passing pointer of char array to function

From Dev

passing function pointer in c with a pointer argument

From Dev

C - Opening a file and reading char by char with passing the file pointer as argument

From Dev

c struct passing itself as an argument into a pointer function

From Dev

Passing an argument to function pointer

From Dev

Char passing argument in c

From Dev

Calling a C function from Julia and passing a 2D array as a pointer of pointers as argument

From Dev

Passing Array of Structs to a Function as a Pointer (C)

From Dev

Passing in an element in an array as a pointer in a function in C

From Dev

Passing an array as a function argument in C++

From Dev

function with a struct array pointer as an argument, C language

From Dev

How to pass a float array to the function that has unsigned char pointer as an argument?

From Dev

C programming passing a char array into a function

From Dev

C18 Passing a char array to function

From Dev

Passing a pointer to an array to a function

From Dev

Passing char pointer to another function: blank value. c++

From Dev

ANSI C - passing data from function to a CHAR pointer

From Dev

Passing char array to function

From Dev

Passing a signed char array to function expecting const char pointer results in garbled array value

From Dev

How to point to the expected char array after passing char* into a function in C?

From Dev

How to point to the expected char array after passing char* into a function in C?

From Dev

C - Passing pointer to function

From Dev

Passing a pointer to a member function as argument for a void* function

From Dev

Passing an array of an array of char to a function

From Dev

Passing an array of an array of char to a function

From Dev

C *char pointer to char array

Related Related

  1. 1

    Passing a pointer to a char array as an argument to a function - C

  2. 2

    Passing char pointer as argument to function

  3. 3

    Passing a char pointer array to a function

  4. 4

    Passing pointer of char array to function

  5. 5

    passing function pointer in c with a pointer argument

  6. 6

    C - Opening a file and reading char by char with passing the file pointer as argument

  7. 7

    c struct passing itself as an argument into a pointer function

  8. 8

    Passing an argument to function pointer

  9. 9

    Char passing argument in c

  10. 10

    Calling a C function from Julia and passing a 2D array as a pointer of pointers as argument

  11. 11

    Passing Array of Structs to a Function as a Pointer (C)

  12. 12

    Passing in an element in an array as a pointer in a function in C

  13. 13

    Passing an array as a function argument in C++

  14. 14

    function with a struct array pointer as an argument, C language

  15. 15

    How to pass a float array to the function that has unsigned char pointer as an argument?

  16. 16

    C programming passing a char array into a function

  17. 17

    C18 Passing a char array to function

  18. 18

    Passing a pointer to an array to a function

  19. 19

    Passing char pointer to another function: blank value. c++

  20. 20

    ANSI C - passing data from function to a CHAR pointer

  21. 21

    Passing char array to function

  22. 22

    Passing a signed char array to function expecting const char pointer results in garbled array value

  23. 23

    How to point to the expected char array after passing char* into a function in C?

  24. 24

    How to point to the expected char array after passing char* into a function in C?

  25. 25

    C - Passing pointer to function

  26. 26

    Passing a pointer to a member function as argument for a void* function

  27. 27

    Passing an array of an array of char to a function

  28. 28

    Passing an array of an array of char to a function

  29. 29

    C *char pointer to char array

HotTag

Archive