caesar cypher

This is a discussion on caesar cypher within the C Programming forums, part of the General Programming Boards category; You were right it was the new line :-). I've fixed it and it works perfectly now.. thanks for all ...

  1. #16
    Registered User
    Join Date
    Apr 2008
    Posts
    38
    You were right it was the new line :-). I've fixed it and it works perfectly now.. thanks for all the help !

    Let me know if I could've done this in a better way:

    Code:
    for(i=0;sent[i];i++){
                    if(sent[i] == ' ')
                      sent[i] = ' ';
                    else if((sent[i] + a) > 'Z')
                      sent[i] = 'A' + ((sent[i] + a) - 'Z')-1;
                      else if(!(isalpha(sent[i])))
                        sent[i] = ' ';
                    else
                      sent[i] += a;

  2. #17
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I'd swap the places of the two, so that you're checking to make sure it's alphabetic before you check to see if it's greater than Z. Better still, just:
    Code:
    if isalpha
        cypher it
    else
        output as-is or as a space, pick one

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #18
    Registered User
    Join Date
    Apr 2008
    Posts
    38
    Alright thanks

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

Similar Threads

  1. Caesar Cipher
    By dldsob in forum C++ Programming
    Replies: 7
    Last Post: 07-06-2009, 07:06 PM
  2. Another Caesar Cipher
    By Swordsman in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2007, 09:56 AM
  3. Caesar Cypher
    By Tommo in forum C Programming
    Replies: 10
    Last Post: 06-29-2007, 01:21 PM
  4. Help with Caesar cipher
    By jcmichman in forum C++ Programming
    Replies: 1
    Last Post: 04-05-2005, 11:50 AM
  5. My little Caesar cipher emulator
    By dead_cell in forum C++ Programming
    Replies: 3
    Last Post: 01-16-2004, 01:05 AM

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