1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

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