Guest User

Untitled

a guest
Jul 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4. #include<malloc.h>
  5. char *strsqz (char ch1[], char ch2[]);
  6. void main()
  7. {
  8.     char static ch1[256],
  9.     char temp[256],ch2[256];
  10.     char  * ch3;
  11.     printf("Please enter the first string: \n");
  12.     gets(temp);
  13.     ch3=(char*)malloc(sizeof(ch3)*strlen(temp));
  14.     printf("Please enter the second string: \n");
  15.     gets(ch2);
  16.     if((strcmp(temp,"")==0)||(strcmp(temp,NULL)==0))
  17.         ch3=strsqz (ch1, ch2);
  18.     else
  19.       ch3=strsqz (temp, ch2);
  20.     puts(ch3);
  21. }
  22. char *strsqz ( char ch1[], char ch2[])
  23. {
  24.   int chLen=strlen(ch1),i;
  25.   int writeIndex=0;
  26.   char *temp=(char*)malloc(sizeof(temp)*chLen);
  27.   for(i=0;i<chLen;i++)
  28.   {
  29.     if(strchr(ch2,ch1[i])==NULL)
  30.     {
  31.         temp[writeIndex]=ch1[i];
  32.         writeIndex++;
  33.     }
  34.   }
  35.   temp[writeIndex]='\0';
  36.   return temp;
  37. }
Add Comment
Please, Sign In to add comment