-
#define and structs
I'm working on an enigma machine simulator. I'd supposed to do a #define for each one of the rotors and reflectors. How do you do a #define for a char string? I have the program partially functional without using #define, so I'd like there to be as little changes as possible after using #define.
Code:
/*reflectors*/
char B_ref_rotor[27] = "YRUHQSLDPXNGOKMIEBFZCWVJAT";
char C_ref_rotor[27] = "FVPJIAOYEDRZXWGCTKUQSBNMHL";
/* rotors */
char rotor[5][27] = {
"EKMFLGDQVZNTOWYHXUSPAIBRCJ",
"AJDKSIRUXBLHWTMCQGZNPYFVOE",
"BDFHJLCPRTXVZNYEIWGAKMUSQO",
"ESOVPZJAYQUIRHXLNFTGKDCMWB",
"VZBRGITYUPSDNHLXAWMJQOFECK",
};
After I get that figured out, I need to use structs and typedefs for whenever I want to access the rotor strings. I think it will be something like the following, but I'm not exactly sure.
Code:
struct rotors {
char rotor[5][27];
};
typedef struct rotors Rotor;
Thanks everyone.
-
Why do you think you need a #define? Do you want:
Code:
#define FOO "thisisastringthatwillbewhereveryouuseFOO"
Or what?
Quzah.