PLEASE!!! help intersections problems
i have to write a program that takes two inputs as arrays and then outputs the intersection.
please help as im really new at this, lol.
here is what i have come up with so far.
Code:
void main()
{
char a[7];
char b[7];
char out[7];
printf( "Please enter your name in lower case: " );
fgets( a, 7, stdin );
printf( "Enter your last name: " );
fgets( b, 7, stdin );
printf( "\nString 'a' %s \n", a);
printf( "\nString 'b' %s \n", lastname);
if (a[0] == b [0]) {
out[0] = a[0];
}
else if (a[1] == b [1]) {
out[1] = a[1];
}
else if (a[2] == b[2]) {
out[2] = a[2];
}
else if (a[3] == b [3]) {
out[3] = a[3];
}
else if (a[4] == b[4]) {
out[4] = a[4];
}
else if (a[5] == b[5]) {
out[5] = a[5];
}
else if (a[6] == b[6]) {
out[6] = a[6];
}
printf( "\nThe intersection is %s \n", out);
getchar();
}
when i run this program, if any of the if statments are met it just seems to put the whole lot in to the output (fullname)
any help welcome