Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.

How to pass an array of string as pointers to a funtion?

For example i have one function void function(how to pass array of string as pointers?)

I have an array of program id for example i.e,P30234,P30324,P34253, and i want to pass these values to the function i mentioned above.Show me how to point to these array, how to pass them as a pointer in function.

and also how do you loop it to access each string at a time. Don't just explain in words, I need answers as examples. Thanks alot.

2 Antworten

Relevanz
  • vor 1 Jahrzehnt
    Beste Antwort

    Here's how to prototype and call functions with arrays, references and

    pointers.

    // one dimension with pointer

    void function(int *a);

    int array[10];

    function(array);

    // two dimensions with pointer

    void function(int (*a)[20]);

    int array[10][20];

    function(array);

    // three dimensions with pointer

    void function(int (*a)[20][30]);

    int array[10][20][30];

    function(array);

    // one dimension with reference

    void function(int (&a)[10]);

    int array[10];

    function(array);

    // two dimensions with reference

    void function(int (&a)[10][20]);

    int array[10][20];

    function(array);

    // three dimensions with reference

    void function(int (&a)[10][20][30]);

    int array[10][20][30];

    function(array);

    If your 2d array is dynamic then you need to allocate some memory for it and

    use pointers. E.g.

    void function(int** a);

    int **array;

    array = new int*[size];

    for (int i = 0; i < size; ++i)

    array[i] = new int[size];

    function(array);

  • vor 4 Jahren

    seem into the "new" operator because it pertains to arrays, then use it to allocate a clean character array for each get entry to in an array of regulations-to-char. this would artwork: char* sentence[ 20 ]; .... sentence[ i ] = new char[ one hundred ]; // undecided of the syntax right here. desire that helps.

Haben Sie noch Fragen? Jetzt beantworten lassen.