hi, i'm having trouble sorting 2 arrays..
char array1[10];
char array2[10];
i want to print out all characters that exist in both array1 + array2, but not the elements that are not common..
Please Help!
Dave
hi, i'm having trouble sorting 2 arrays..
char array1[10];
char array2[10];
i want to print out all characters that exist in both array1 + array2, but not the elements that are not common..
Please Help!
Dave
only 'f' an 'a' from string1 exitst in string2...these are all that are outputted.....Code:#include <stdio.h> #include <string.h> int main(void){ char string1[] = "foobar"; char string2[] = "flashdaddee"; for(unsigned int y = 0; y < strlen(string1); y++){ for(unsigned int x = 0; x < strlen(string2); x++){ if(string1[y] == string2[x]){ printf("%c\n",string1[y]); break; } } } return 0; }
Oh... I used char arrays, but the principle applies to other arrays too
Last edited by Fordy; 11-22-2001 at 02:00 PM.
Thank you so very very much, i really appreciate this, i've been tormented with this one for months (bit of a newie)
thanks!
cprogramming.com rocks
Dave