Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2009
    Location
    In a little room all alone with a kickass computer :D
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Encryption help in C++

    I'm using a method of half for encrypting simple text:

    Code:
    char txt[100],txtc[100];
    strcpy(txt,"HELLO");
    
    txtc[0]=txt[0];
    for(i=1;txt[i]!=0;i++)
    {
       if(txt[i-1]%2==1)
          txt[i-1]+=1;
       txtc[i]=(txt[i-1]/2)+(txt[i]/2);
    }
    Now assuming that this code would be decrypted in a logical way, can you tell me why do I encounter segmentation fault while the code is being processed?

    And can someone say why my reputation is negative?? :|
    Last edited by testware; 11-23-2009 at 09:05 PM. Reason: resolved on my own

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by testware View Post
    Now assuming that this code would be decrypted in a logical way, can you tell me why do I encounter segmentation fault while the code is being processed?
    Worked for me.

    Quote Originally Posted by testware View Post
    And can someone say why my reputation is negative?? :|
    Go to the User CP, you can see your reputation score and the comments on any reputation given.
    OracleGuy

  • #3
    New Coder
    Join Date
    Oct 2009
    Location
    In a little room all alone with a kickass computer :D
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Fixed it

    Had to add a 0 to the last value:

    txtc[i]=0;

    Somehow that was running into an error at runtime.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •