Thread: #define and structs

  1. #1
    Registered User
    Join Date
    Nov 2009

    #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.

    char B_ref_rotor[27] = "YRUHQSLDPXNGOKMIEBFZCWVJAT";
    char C_ref_rotor[27] = "FVPJIAOYEDRZXWGCTKUQSBNMHL";
    /* rotors */
    char rotor[5][27] = { 
    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.

    struct rotors {
    	char rotor[5][27];
    typedef struct rotors Rotor;
    Thanks everyone.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Why do you think you need a #define? Do you want:
    #define FOO "thisisastringthatwillbewhereveryouuseFOO"
    Or what?

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 11-12-2008, 11:00 AM
  2. how to ordered const structs
    By tnr in forum C Programming
    Replies: 2
    Last Post: 12-14-2007, 07:13 AM
  3. Nested Structs
    By Monkey83 in forum C Programming
    Replies: 2
    Last Post: 09-15-2006, 11:03 AM
  4. display copied data into structs
    By bazzano in forum C Programming
    Replies: 5
    Last Post: 05-02-2006, 02:12 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM