change text

This is a discussion on change text within the C Programming forums, part of the General Programming Boards category; You can use another switch, or just create tables: encode[] = {'a', 'b', 'c', 'd'}; decode[] = {'l', 'j', 'g', ...

  1. #16
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    You can use another switch, or just create tables:

    encode[] = {'a', 'b', 'c', 'd'};
    decode[] = {'l', 'j', 'g', 'w'};

    Instead of using switch statements, you just scan your tables until you hit the index you want and use the other table to encode/decode.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  2. #17
    Now that I know how to use a switch with this problem I would like to khow how to use tables such as:

    encode[] = {'a', 'b', 'c', 'd'};
    decode[] = {'l', 'j', 'g', 'w'};

    I want to be able to reverse what I encoded. A switch does not seem to be the way to do it since I don't think I can reverse a switch without rewriting the cases.....

    Any idea on how to proceed!!!!

    need the help badly!

  3. #18
    Registered User
    Join Date
    Mar 2002
    You could always encode the test using an exclusive or statement though its not too secure unless every value you use to encode with is different, ie:
    char password[10];
    char text[50];
    char newtext[50];
    int passlength;
    int passcounter;
    int textlength;
    int textcounter;
      newtext[textcounter] = text[textcounter] ^ password[passwordcounter]
    only problem is it will encode every letter in the text, to decode the text just run the text through the program again, using the exact same password. I think the ^ is XOR, not 100% though.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to use FTP?
    By maxorator in forum C++ Programming
    Replies: 8
    Last Post: 11-04-2005, 03:17 PM
  2. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 08:55 AM
  3. change color text?
    By k4z1nh0 in forum C Programming
    Replies: 4
    Last Post: 03-15-2005, 11:41 AM
  4. help with calculating change from a dollar
    By z.tron in forum C++ Programming
    Replies: 3
    Last Post: 09-13-2002, 04:58 PM
  5. Replies: 2
    Last Post: 09-04-2001, 03:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21