S
stevenruiz
Hello All
My question mainly is how to use/reference Double Pointers? I am
currently trying to understand what the meaning of a 'vector of
pointers' means also? What I am trying to do is take a char array and
break it up into words omitting the spaces. What needs to be noted is
that I am trying to accomplish this only using char ** and char *.
Therefore, I am creating it from scratch. Below is code that I have
written so far:
int main()
{
char input[125] = " Hello World\0"
char **doublePointer;
char *receiveArray;
doublePointer = malloc(125 * sizeof(char *));
receiveArray = input;
int i;
for(i = 0; receiveArray [ i ] != '\0'; i++)
{
//Here I am confused
//I'm not sure how to traverse the array and store data into
// the double pointer/vector
//Do I need to do this
// doublePointer [ i ] = malloc ( sizeof( char * ));
}
free(doublePointer);
return 0;
}
Any hints and suggestions about the algorithm/design would be
welcome. Thanks.
My question mainly is how to use/reference Double Pointers? I am
currently trying to understand what the meaning of a 'vector of
pointers' means also? What I am trying to do is take a char array and
break it up into words omitting the spaces. What needs to be noted is
that I am trying to accomplish this only using char ** and char *.
Therefore, I am creating it from scratch. Below is code that I have
written so far:
int main()
{
char input[125] = " Hello World\0"
char **doublePointer;
char *receiveArray;
doublePointer = malloc(125 * sizeof(char *));
receiveArray = input;
int i;
for(i = 0; receiveArray [ i ] != '\0'; i++)
{
//Here I am confused
//I'm not sure how to traverse the array and store data into
// the double pointer/vector
//Do I need to do this
// doublePointer [ i ] = malloc ( sizeof( char * ));
}
free(doublePointer);
return 0;
}
Any hints and suggestions about the algorithm/design would be
welcome. Thanks.