Thread: Question, Im very new

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    2

    Question, Im very new

    Alright, I am planning on writing a program to encrypt text using the Caesar cipher. To do this I was planning on isolating each character and then performing the operations to encrypt on that character. However I do not know how to isolate that character from the inputed text.
    How would I do that?
    Is there a better way?

  2. #2
    Registered User
    Join Date
    Oct 2009
    Posts
    2
    I am sorry, but I have never done any real programming. I know HTML and Basic pretty well. But that dose not compare to C.

  3. #3
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    You need to learn how to walk before you run. Get a decent text on the C programming language, learn it, and then try your program. As for a text, since you have done some programming, I think The C Programming Language Second Edition, by Brian Kernighan & Dennis Ritchie might be good for you. It is pretty much the standard for C programming texts.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by Penguinlord View Post
    Alright, I am planning on writing a program to encrypt text using the Caesar cipher. To do this I was planning on isolating each character and then performing the operations to encrypt on that character. However I do not know how to isolate that character from the inputed text.
    How would I do that?
    Is there a better way?
    There is no better way - the algorithm for an efficient Caesar cipher, is the same, in any language.

    in C, there are no strings - almost. Each char is already separated from the others, so instead of this, in BASIC:

    Code:
    FOR i = 1 TO LEN(string$) STEP 1
     mychar$ = MID$(string$, i, 1) 
    NEXT i
    
    C does this:
    char string[] = {"Once a jolly swagman"}; //compiler will count the spaces needed
    
    for(i = 0; i <= strlen(string); i++)  //you should #include <string.h> when using strlen()
      mychar = string[i];                      //the name of the array is it's base address in C
    
    
    //curly braces are optional if the parent expression has just one child 
    //expression:
    
    length = strlen(string);    //this is more efficient than re-calculating 
    for(i = 0; i <= length; i++) {  //strlen(string) within the for loop
      mychar = string[i];
    }
    Enjoy C, and welcome to the forum.

  5. #5
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    Posts
    356
    You need to learn how to walk before you run.
    sometimes you need to run to learn how to walk
    "I wish i could wish my wishs away"

    "By indirections find directions out" -- William Shakespears

    "Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666"

    Mizra -> love = Death...
    RDB(Rocks yooo)..

    http://www.cbeginnersunited.com

    Are you ready for the Trix ???

  6. #6
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by datainjector View Post
    sometimes you need to run to learn how to walk
    Err... no!
    If you were looking for an analogy to support that idea I would have used: "Sometimes you have to be thrown out of the nest to learn how to fly."

    But no, being thrown in the deep end in programming is seldom a good idea.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  7. #7
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Quote Originally Posted by iMalc View Post
    Err... no!
    If you were looking for an analogy to support that idea I would have used: "Sometimes you have to be thrown out of the nest to learn how to fly."

    But no, being thrown in the deep end in programming is seldom a good idea.
    And yet you'd think, with all the students coming in saying "Our teacher just gave this linked list assignment and doesn't teach us anything...so what's a loop?" it happens all the time.

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    As a former lifeguard and water safety instructor, I can tell you, it's not the way to learn to swim, either.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM

Tags for this Thread