#include #include #include #define STRSZE 200 /*------------------------------------------------------------------------ * MySubstr() copies a substring from 'infile' starting at index 'start' * and ending at index 'end' into a static variable. A character pointer * to this static variable is returned. If this routine is called multiple * times be aware of the use of our static variable. *------------------------------------------------------------------------ */ char *MySubstr(char *infile, int start, int end) { int x, y=0; static char returnstr[STRSZE]; for (x=start; x0; x--){ if (astring[x]==' ' || astring[x]=='\n' || astring[x]=='\t') astring[x]='\0'; else x=0; } } /*------------------------------------------------------------------------ * MyStrip() removes leading and trailing characters 'ch' from 'line' *------------------------------------------------------------------------ */ void MyStrip(char *line, char ch) { int i, x, y, z, size; char newline[STRSZE]; size = strlen(line); i=0; x=0; y=size; // get rid of leading characters while (line[x]==ch){ x++; } // get rid of trailing characters and '\0' while (line[y]==ch || line[y]=='\0'){ y--; } // copy the string for (z=x ;z