/* A Test of the split function */ #include #include "split.h" int readline(char *temp, int n, FILE *f) { char *s=fgets(temp,n,f); int len; if (s==NULL) return (0); len=strlen(temp); if (len>0) { if (temp[len-1]=='\n') temp[len-1]=0; } else temp[0]=0; return 1; } char *safecopy(char *s) { int len=strlen(s); char *t=(char *)malloc(len+1); strcpy(t,s); return (t); } void main(void) { char temp[100]; char *parts[50]; int i, n; while (1) { printf("test string? "); n=readline(temp,99,stdin); if (n==0) break; n=split(temp,parts); printf("%d substrings:\n"); for (i=0; i