Explain Squeeze Function C language

CServer Side ProgrammingProgramming

Squeeze(s1,s2) or squeeze(char[],char[]) is a user defined function which is used to delete the common characters or equal characters in two strings.


How to delete the common characters in two strings using squeeze function in C programming language?


In this program, the user enters two strings in the console and write a code to display first string excluding the common characters present in second string.


The C program which demonstrates the functioning of squeeze function is as follows −

 Live Demo

void squeeze(char string1[],char string2[]);//prototype declaration
int main(){
   char string1[50];
   char string2[30];
   printf("enter the string1:");
   scanf("%s",string1);// read string1 from keyboard
   printf("enter the string2:");
   scanf("%s",string2);// read string2 from keyboard
   squeeze(string1,string2);//call squeeze function
   printf("Final string is:%s\n",string1);
   return 0;
void squeeze(char string1[],char string2[]){
   int i,j,k;
      for(j=0;string2[j]!='\0' && string2[j]!=string1[i];j++)


The output is stated below −

Enter the string1 : Tutorial
Enter the string2 : ut
Final string : Torial
Published on 10-Mar-2021 09:42:26