Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- #include<malloc.h>
- char *strsqz (char ch1[], char ch2[]);
- void main()
- {
- char static ch1[256],
- char temp[256],ch2[256];
- char * ch3;
- printf("Please enter the first string: \n");
- gets(temp);
- ch3=(char*)malloc(sizeof(ch3)*strlen(temp));
- printf("Please enter the second string: \n");
- gets(ch2);
- if((strcmp(temp,"")==0)||(strcmp(temp,NULL)==0))
- ch3=strsqz (ch1, ch2);
- else
- ch3=strsqz (temp, ch2);
- puts(ch3);
- }
- char *strsqz ( char ch1[], char ch2[])
- {
- int chLen=strlen(ch1),i;
- int writeIndex=0;
- char *temp=(char*)malloc(sizeof(temp)*chLen);
- for(i=0;i<chLen;i++)
- {
- if(strchr(ch2,ch1[i])==NULL)
- {
- temp[writeIndex]=ch1[i];
- writeIndex++;
- }
- }
- temp[writeIndex]='\0';
- return temp;
- }
Add Comment
Please, Sign In to add comment