fork(1) download
  1. void IndexMap(char *);
  2. int output[26] = {0};
  3. int main ()
  4. {
  5. int n;
  6. int indx;
  7. char string[3][255];
  8. printf ("How many strings want to enter");
  9. scanf("%d", &n);
  10. /* Find common characters from all the entered stings */
  11. for (indx = 0; indx < n; indx++)
  12. {
  13. printf("Enter %d string\n", indx+1);
  14. scanf("%s", string[indx]);
  15. IndexMap(string[indx]);
  16. }
  17. for (indx = 0; indx < 26; indx++)
  18. {
  19. if (output[indx] == n)
  20. printf("Common character [%c] from all strings\n", 'a'+ indx);
  21. }
  22. return 0;
  23. }
  24. void IndexMap(char *string)
  25. {
  26. while (*string != '\0')
  27. output[*string++ - 'a']++;
  28. }
Success #stdin #stdout 0s 2116KB
stdin
3
abcdde
baccd
eeabg
stdout
How many strings want to enterEnter 1 string
Enter 2 string
Enter 3 string
Common character [a] from all strings
Common character [b] from all strings
Common character [c] from all strings
Common character [d] from all strings
Common character [e] from all strings