Since C has no feature to extract part of a string from a string (like PHP's substr does) I thought I'd modify an existing routine...
int substr(char **tFrom,int tTo,int tOffset, int tLen) {
tTo = (char*) malloc(strlen(tFrom));
strncpy(tTo, tFrom+2, 5);
return tTo;
}
Any idea why this doesn't work?
tTo = (char*) malloc(strlen(tFrom));
^
clparse.c(47) : Error: need explicit cast to convert
from: char *
to : int
strncpy(tTo, tFrom+2, 5);
^
clparse.c(48) : Error: need explicit cast for function parameter 1 to get
from: int
to : char *
--- errorlevel 1