Thread: Encryption in c++

  1. #1
    Registered User
    Join Date
    May 2015
    Posts
    5

    Post Encryption in c++

    Hi, i want to make a encryption in c / c++, but when i execute a program print only last char, yes, i know char is a single latter, but when i put std::string text = "som... i can't use this: (int(text));
    Help.
    Code:
        char text = 'some text';
        
        // Encryption
        int x = (int(text));
        x = x * 8 - 300 * 2;
        cout << x;
        char y = x;
        cout << y;

  2. #2
    Guest
    Guest
    I'm not entirely sure I understand you goal. If you want to store multiple chars in a variable, you will need to create an array thereof, just like with any other type.

    std::string has the c_str method which gives you access to the underlying char array, if that's what you're looking for.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    And just what is (int(text)) supposed to do? Are you trying to get the numerical value of each character? If so, just loop over each character in the string in a loop. A character is just a numerical value.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 03-08-2012, 05:37 PM
  2. XOR Encryption
    By mikeman118 in forum C++ Programming
    Replies: 57
    Last Post: 08-10-2007, 10:21 AM
  3. XOR encryption
    By Neo1 in forum C++ Programming
    Replies: 14
    Last Post: 06-11-2007, 05:13 PM
  4. Encryption
    By ffejnoddap in forum C++ Programming
    Replies: 4
    Last Post: 06-01-2002, 03:11 PM
  5. XOR Encryption???
    By kas2002 in forum C++ Programming
    Replies: 8
    Last Post: 05-30-2002, 06:24 AM

Tags for this Thread