September 7th, 2003, 05:36 AM
-
compile errors? can u check them?
Hi, please help.
I have compile errors
"assignment makes pointer from integer without a cast"
for the below code.
Can anyone tell me how to fix this?
Thanks in advance.
void set_paths() {
char * path;
char * ch;
char * chp;
int i;
path = getenv("PATH");
printf("PATH: %s\n", path);
ch = path;
i = 1;
while ( (ch = index(ch, ':')) != NULL) { ++i; ++ch; }
paths = (char **)malloc( (i+1) * sizeof(char *));
paths[0] = path;
ch = chp = path;
i = 1;
while ( (ch = index(ch, ':')) != NULL) {
*ch = 0;
i ++;
ch ++;
paths[i] = chp;
chp = ch;
printf("Path %d: %s\n", i, paths[i]);
}
paths[i] = 0;
path_nr = i;
}
September 7th, 2003, 05:51 AM
-
1) Post code in code tags to preserve the formatting
2) Include in the posted code the missing declarations (paths, path_nr, index() )
3) State or indicate at which line the error is reported.
Clifford
September 8th, 2003, 01:22 PM
-
what is the resutn type of index function ?
May I know the return type of index function