I've tried this over and over and can't get this right. This is only a snippet of my code. I keep on getting this error:
"testcode.c:21:31: error: incompatible integer to pointer conversion assigning to 'string' (aka 'char *') from 'char'; take the address with & [-Werror,-Wint-conversion] ciphertext[x] = sub[x]; ^ ~~~~~~ &"
I've seen other people do similar, and it compiles for them, so I'm not understanding why it's giving me this error. Thanks for any insight!
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(int argc, string argv[])
{
string plain = get_string("plaintext: ");
string key = argv[1];
string Ualphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// Using plaintext, get position of alphabet
string ciphertext[strlen(plain)];
for (int i = 0, n = strlen(plain); i < n; i++)
{
for (int x = 0; x < strlen(plain); x++ )
{
if (plain[x] == Ualphabet[i])
{
ciphertext[x] = key[x];
printf("%c", ciphertext[x]);
}
}