I'm trying to add a space before and after a user input. I have the space after using strcat() but cant figure out how to put one before. Here is the snippet.
void find_keyword()
{
int len=0;
int lenkey=0;
int key_no=0;
char teststr[50];
while((ip.keyfound==0) && (key_no!=MAX_KEY))
{
// getting the length of the keyword
lenkey=strlen(keys[key_no].getword());
char *ptr=NULL;
// Concatenated the user input to include a space. This fixes accidental keyword hits.
strcat(ip.userip, " ");
ptr=strstr(ip.userip,keys[key_no].getword());
if (ptr!=NULL)
{
// keyword found !
ip.keyfound=1;
ip.keyno=key_no;
strcpy(ip.keyword,keys[key_no].getword());
break;
}