while (1)
{
char j;
if (x[j] == y[j])
Here I am trying to start a loop where I want to able to match any of the characters from char array ‘x’ with char array ‘y’. If the characters do match from x to y then I want to keep them as they are and if they don’t I want to be able to replace them with a star ‘*’. (e.i. x = [a,p,f] and y = [a,p,p,l,e] and so after the match up and replacement y = [a,p,p,*,*] and when I cout it spells out app**)
I have no idea how to set this up and what type of loop I should use. I fairly new to programming and I know basic replace and switch functions.
This more or less does what you specify, I think.
Test program
@LooneyTunes asks what happens with:
x[] = "apcd"andy[] = "abcd"– do you get"a*cd".The answer is yes. Here’s a test program that demonstrates the results. As far as I am concerned, it is pure C code, though G++ is quite happy with it too. You might need the C99 option such as ‘
-std=c99‘ with GCC set on the compiler. MSVC won’t like it if it compiles this as C code; declarejat the top of the function for it.Output