Hi to all,

Need some help with a function I'm trying to write, if I may. The object of the function is to read through a comma delimited file placing the data between the commas into individual elements of the array, to be worked on by the calling program. What I have so far is -

Code:
int get_info(FILE *fp, fpos_t seek_ptr, char (*ptr)[MAX_REC])
{
  char buffer[28];
  int x, n, t;
  char *p, ch;

  p = (char *)ptr;
  fsetpos(fp, &seek_ptr);

  while(ch != ';')  // End of field pointer
  {
    ch = fgetc(fp);

    if(ch == '{' || ch == ' ') { t = 0; }  // Remove header info

    if(ch == ',')
    {
      ch = '\0'
      buffer[t++] = ch;

      if (( p = (char *)malloc(strlen(buffer)+1)) == NULL)
        return -1;
      strcpy(p[n++], buffer);
      ch = 0; t = 0;
    }
    if( ch == '}')  // Reached end of a line
   {
      ch = '\0';
      buffer[t++] = ch;

      if (( p = (char *)malloc(strlen(buffer)+1)) == NULL)
        return -1;
      strcpy(p++, buffer);
      ch = 0; t = 0;
    }
    buffer[t++] = ch;
  }
  return o;
}
I've obviously done something seriously wrong because all this does is hang the computer, I've been staring at this code for too long and just can't see it. Any help greatly appreciated!