Hi, all--
I'm writing a program to find the longest common prefix of two words (e.g. input "department" and "depart", get "depart" back; input "global" and "glossary", get "glo" back), and when I attempt to compile, I get the above warning. Here's my code, with the line in question in red:
Code:
#include <stdio.h>
#include <string.h>
int main()
{
char one[11], two[11], prefix[11];
int i = 0, len;
printf("Please enter two words: ");
scanf("%s%s", one, two);
if(strlen(two) < strlen(one))
{
len = strlen(two);
}//if(strlen(two) > strlen(one))
else
{
len = strlen(one);
}
while(one[i]==two[i] && i < len)
{
strcat(prefix, one[i]);
i++;
}//while one[i]==two[i] -- tests each letter of one and two, and if they're the same, appends letter to prefix
printf("The longest common prefix of %s and %s is %s.", one, two, prefix);
return 0;
}//main
I'm not sure what I'm doing wrong or how to fix it. Any help would be greatly appreciated.