I am having writer's block at the moment.
What I want is to have a sort that will check if newWord equals to wordInput, and if it doesn't, it will keep swapping around letters until it does. For example, let's say wordInput is poop and newWord is oopp, I want newWord to eventually turn into poop, so how can I swap that around?
This is the code I have so far.
#include<stdio.h>
#include<string.h>
int main(){
char wordInput[25];
char newWord[25];
char tmp;
int len;
int a, b;
wordInput = "poop";
newWord = "oopp";
len = strlen( newWord );
// Sort back to wordInput
for( a = 1; a < len; a++ ){
for( b = 0; b < len - a; b++ ){
if( newWord[b] != wordInput[b] ){
tmp = newWord[b];
newWord[b] = newWord[b + 1];
newWord[b + 1 ] = tmp;
}
}
}
printf( "Back to original input: %s\n", newWord );
}