Im trying to return a pointer to a string in my function and assign to another char array to print it out. But i get a conflicting type error for my function.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
const char *s = "[[random text]]";
const char *P1 = "[[";
const char *P2 = "]]";
const char *result = parseString(s,P1,P2);
printf("%s",result);
}
void const char* parseString(char* str,char* first, char* snd)
{
char *target = NULL;
char *start, *end;
if ( start = strstr( str, first ) )
{
start += strlen( first );
if ( end = strstr( start, snd ) )
{
target = ( char * )malloc( end - start + 1 );
memcpy( target, start, end - start );
target[end - start] = '\0';
}
}
return target;
}