fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(){
  6. char str1[100], str2[100];
  7. int size1,size2, i,j;
  8. printf ("Give the first string: ");
  9. scanf ("%s", str1);
  10. printf ("Give the second string: ");
  11. scanf ("%s", str2);
  12.  
  13. size1= strlen(str1);
  14. size2= strlen(str2);
  15.  
  16. for(i = 0; i < size1; i++) {
  17. for(j = 0; j < size2; j++) {
  18. if(str1[i] == str2[j]) {
  19. str1[i] = ' ';
  20. str2[j] = ' ';
  21. }
  22. }
  23. }
  24.  
  25. // removing empty spaces for string 1
  26. for(i = 0; i < size1; i++){
  27. if(str1[i] == ' ') {
  28. for(j = i; j < size1; j++) {
  29. str1[j] = str1[j + 1];
  30. }
  31. size1--;
  32. }
  33. }
  34.  
  35. // removing empty spaces for string 1
  36. for(i = 0; i < size2; i++){
  37. if(str2[i] == ' ') {
  38. for(j = i; j < size2; j++) {
  39. str2[j] = str2[j + 1];
  40. }
  41. size2--;
  42. }
  43. }
  44.  
  45. printf("%s\n", str1);
  46. printf("%s\n", str2);
  47.  
  48. return 0;
  49. }
Success #stdin #stdout 0s 5420KB
stdin
abcdabcdabcd
bcd
stdout
Give the first string: Give the second string: a abcdabcd