I want to pass two variables into a function in C - one being a string and the other being an individual character from a string.
However, I am not really sure how to use the function without either getting the "Expected Expression" error:
int spaces_away(string cipher[], string plain[char i]);
or getting an "undeclared identifier" error as well:
int spaces_away(string cipher[], char plain[i]);
I think it is also important to add that the variable "i" is from a "for" loop in the code and this is what my code looks like inside of main as of now:
{
// Error if there are not two arguments
if (argc != 2)
{
printf("Command Line Must Have Two Arguments\n");
return 1;
}
// Error if there are not 26 characters in encryption
else if (strlen(argv[1]) != 26)
{
printf("Cipher must have 26 characters\n");
return 1;
}
else
// Takes a word and encrypts it by a user given alphabet
{
string stdWord = get_string("plaintext: ");
for (int i = 0, n = strlen(stdWord); i < n; i++)
{
encrypt[i] = (stdWord[i] + spaces_away(argv[1], tolower(stdWord[i]));
}
printf("ciphertext: %s\n", (string) encrypt);
return 0;
}
}