I'm trying to get a string with unknown length and i used this weird code:
It seems not working . Any suggestions for how to get it worked?Code:int main() { char *ptr int l; ptr = (char *) malloc(sizeof(char *) * 10); while(scanf("%s", ptr) == 1) { l = strlen(ptr); if(l>10) ptr = (char *) realloc(ptr,sizeof(char *) * (l-10)); } .... return 0; }



LinkBack URL
About LinkBacks





(old C style definition)