[C Language Pointer] Triple Pointer Parameter Question!

Asked 2 years ago, Updated 2 years ago, 37 views

//int test(char*** token_list) {
    char temp[3] = { "apple","bee","carrot" };
    //Put the created temp into token_list
}

What should I do to get the temp into the token_list?

c pointer

2022-09-21 11:33

1 Answers

I don't know exactly what the question is. I'll give you a rough example.

#include <string.h>


void fill_string(char buf[3][100])
{
    char default_string[3][100] = { "apple", "bee", "carrot" };
    int i = 0;

    for(i = 0; i < 3; i++)
    {
        strcpy(buf[i], default_string[i]);
    }
}


int main()
{
    char s[3][100] = {0,};
    int i;

    fill_string(s);

    for(i = 0; i < 3; i++)
    {
        printf("%s\n", s[i]);
    }

    return 0;
}


2022-09-21 11:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.