Encrypting User Given String

Discussion in 'C++' started by AnnRose, Apr 30, 2013.

  1. AnnRose

    AnnRose New Member

    Joined:
    Apr 30, 2013
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi all. I am working on a program where a user first enters a string of 26 characters, they then choose the number of lines they'd like to use with a length of 40. I have it working as far as it encrypting a string that I enter into the code, but I don't know how to make it encrypt whatever input the user gives, nor do I know how make the program know how many lines they've chosen to use. I am a beginner/novice at C++, so any help would be greatly appreciated. Thank you in advance. This is the code I have so far:
    Code:
    #include <iostream >
    using namespace std;
    void encrypt(char[]); 
    
    
    int main( )
    {
    int userinput;    
    
    char string[ ] = "USeriNPut";
    
    
    cout << "The Decrypted String is: " << string << endl;
    encrypt(string);
    
    cout << "The Encrypted String is: " << string << endl;
    
    return 0;
    }
    
    void encrypt (char x[] ) 
    {
    for( int i=0; x[i] != '\0'; ++i ) ++x[i];
    }
     
    Last edited by a moderator: May 1, 2013

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice