W
windstorm
for instance,I define a 2-D pointer:
char **input = NULL;
I want the "input" pointer to point to some string,and the number of
the string is dynamic.
when I got the first string,I was code like this:
*input = strtok( row,token );
because the function strtok return a string and the pointer "input" is
just point to this string,so I don't think it is need to be
initialized.There is no error when make but when I run the program
there is a error so-called "core dumped".
I think maybe it's because the pointer "input" wasn't initialized,so I
add something like this(although I don't think it is need):
*input = (char *)malloc( WORD_LENGTH * sizeof(char) );
*input = strtok( row,token );
But the error is still here,the same.
So,I wanna ask,how to initialize the 2D pointer?
I know that there is another way to use char*input[], but the number
the array can store is changeless.Even if I can use array to solve my
problem,but I will be disappointed if I cann't understand the question
I ask.
char **input = NULL;
I want the "input" pointer to point to some string,and the number of
the string is dynamic.
when I got the first string,I was code like this:
*input = strtok( row,token );
because the function strtok return a string and the pointer "input" is
just point to this string,so I don't think it is need to be
initialized.There is no error when make but when I run the program
there is a error so-called "core dumped".
I think maybe it's because the pointer "input" wasn't initialized,so I
add something like this(although I don't think it is need):
*input = (char *)malloc( WORD_LENGTH * sizeof(char) );
*input = strtok( row,token );
But the error is still here,the same.
So,I wanna ask,how to initialize the 2D pointer?
I know that there is another way to use char*input[], but the number
the array can store is changeless.Even if I can use array to solve my
problem,but I will be disappointed if I cann't understand the question
I ask.