Hello i have tried to write a substring function in C
but it wont compile![]()
i still learning C but can someone help me get this working please
PHP Code:
#include <stdio.h>
#include <string.h>
typedef char* string;
string substring(string haystack,int start,int length)
{
char* substr;
int c, i;
if (start > strlen(haystack) || length > strlen(haystack) || (start + length) > strlen(haystack))
{
return(0);
}
else
{
i = 0;
for(c=start;c<(start + length);c++)
{
substr[i] = haystack[c];
i++;
}
return(substr);
}
}





Reply With Quote