#include<stdio.h>
void squeez(char s[],char z[]);
int main()
{
char s[100] = "Hey wassup !!!!!!";
char z[100] = "Wow cool!!!!!";
squeez(s,z);
return(0);
}
void squeez(char s[] , char z[])
{
int j,dummy = 0,i=0;
char x[100];
for(j = 0 ; s[j] != '\0';j++)/* the starting loop */
{
while(z[i] != '\0') /* inner loop */
{
/* the purpose of dummy is to tell weather this if statement became true or not */
if(s[j] = z[i])
{
dummy = 123;
break;
}
else
{
continue;
}
i++;
}
if(dummy != 123)
{
x[j] = s[j];
}
}
printf("%s",x); /* printing out the values */
}
The main aim of making this program is that :-
1. This program/function will delete all those characters in the first string i.e s[] that matches any character in the second string i.e z[] . And copy the new string of characters to x[].
Problems :-
The program is not giving the right output it is printing some garbage value.
Questions:-
Help me with this piece of code . Tell me where i am wrong and what is the solution.
Thank you IN advance.