Hey guys, I'm fairly new to C programming and don't understand pointers very well. This program compares two strings and outputs the suffix (suffix of "globally" and "internally" is "ally"). I am getting this error: suffix.c:21:2: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
It also seg faults if I run the program. What is my problem?
Code:
#include <stdio.h>
#include <string.h>
int main()
{
char first[80];
char second[80];
printf("Please enter the first word: ");
fgets(first, 80, stdin);
printf("Please enter the second word: ");
fgets(second, 80 ,stdin);
int i;
int different = 0;
for(i=1; different == 0; i++) {
if (first[strlen(first)-i] != second[strlen(second)-i])
different = 1;
}
char same[80];
strcpy(same, first[strlen(first)-i]);
printf("%s", same);
return 0;
}//main