home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_09_08
/
9n08098b
< prev
next >
Wrap
Text File
|
1991-06-16
|
838b
|
29 lines
int allocate_space(int nbr, char ***ptrarray, int size, char **string)
{ //Allocate the array pointers
if( (*ptrarray= (char **)calloc(nbr,sizeof(char *))) ==NULL)
return(0); //Allocate the string space ***
if( (*string = (char *)calloc(size+1,sizeof(char))) == NULL)
return(0);
return(1);
}
void free_space(char ***ptrarray, char **string)
{
free(*ptrarray);
free(*string);
}
void str_to_ptrarray(char *orgstr, char *ptrarray[])
{
int i=0;
char *s;
s=strtok(orgstr,word_breaks); //Find the first word
while(*s)
{
ptrarray[i]=s; //assign it
i++;
s=strtok(NULL,word_breaks); //Find the rest of the words
}
}