There's a lot of mistakes in your code. I've added comments to it, starting with //!!
Code:
#include <stdio.h>
#include <string.h>
//Based on 4 1D Arrays;
//alphabet[] is meant to store the regular alphabet.
//cipher[] is meant to store the cipher.
//name[] is meant to store the test name.
//secret[] is meant to store the final encoded result
int main() {
char cipher[30], alphabet[30], name[30], secret[30];
int i=0, j=0, length;
//Filling in the first three arrays
//The Alphabet (26 letters)
strcpy(alphabet, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
//The Substituted Cipher for the Alphabet (26 letters).
strcpy(cipher, "QAZWSXEDCRFVTGBYHNUJMIKOLP");
//The Test name.
strcpy(name, "SARAH");
//Testing the strlen tool
length = strlen(name);
printf("\n The length of the name is %d\n", length);
//The Main Loop should go on until every letter in the test name is covered.
for(i=0; j=0; i < strlen(name)) { //!! Should be more like for (i=0, j=0; i < strlen(name); )
//If the current letter of name and the current letter of alphabet do match:
if (name[i] = alphabet[j]) { //!! To test for equality, use ==
//Copy the letter of cipher that represents the matching alphabetical letter into the current spot of secret, which holds the encoded name.
strcpy(secret[i], cipher[j]); //!! To copy a single char, just use secret[i] = cipher[j]
//Move on to the next letter of the name.
i = i++ ; //!! No! Just use i++
//Reset Alphabetical tracking.
j = 0 ;
}
//Else if the current letter of name and the current letter of alphabet do not match:
else
//move on to the next letter of alphabet.
j = j++; //!! Again, no. Just j++
}
//Once all letters of the name are covered:
if (i = strlen(name)) { //!! To test for equality, use ==
//Print the encoded name from the secret[] array.
printf("\n Your encoded name is %s\n", secret);
//Printing the other 3 rows to check for errors.
printf("\n Alphabet is %s\n", alphabet);
printf("\n Cipher is %s\n", cipher);
printf("\n Real name is %s\n", name);
}
//Current Issue: secret does not come out as intended, wondering if the inputs are happening as they should.
return 0;
}