So, you need to get your input from a string(char*) rather that an input stream(FILE*).
I think, in your case, you can just replace:
// input is a FILE*
if( fgets(line,MAXLINE,input) == NULL )
This may get more than one line, but I don't think this matters in your code.
// input is a char*
strncpy(line, input, MAXLINE);
line[MAXLINE - 1] = '\0';
If you do need only the one line you can use this function:
or maybe someone will post a much nicer way to use sscanf() to do this.
char* GetLineFromString(char* out, int max_length, const char* in)
char* pnew_line = strchr(in, '\n');
char_count = min(max_length - 1, (pnew_line - in) + 1);
char_count = max_length - 1;
strncpy(out, in, char_count);
out[char_count] = '\0';
return (strlen(out) ? out : NULL);
GetLineFromString(line, MAXLINE, input);