I know this one has been asked before, however I can\'t seem to find a suitable solution, so I \'ll state the problem:
I have a string of characters that is similar to a
I would just use strstr():
char * get_value(const char *input)
{
const char *start, *end;
if((start = strstr(input, "")) != NULL)
{
start += strlen("");
if((end = strstr(start, " ")) != NULL)
{
char *out = malloc(end - start + 1);
if(out != NULL)
{
memcpy(out, start, (end - start));
out[end - start] = '\0';
return out;
}
}
}
return NULL;
}
Note that the above is untested, written directly into the SO edit box. So, it's almost guaranteed to contain at least one off-by-one error.