Encrypting/Decrypting strings

Hey guys i just registered and I love this forum, I had my love for programming revived even though I'm a beginner. I have a simple decryption program but I cant get it to encrypt/decrypt text read from the keyboard using getline (), did i declare wrong?

#include <iostream>
#include <string>

using namespace std;

char text[ ]

(here I have my void decrypt/encrypt functions)

int main ()
cout <<''Enter text to encrypt''<<endl;
What went wrong, please help
closed account (Dy7SLyTq)
wrong string. ur using a c-style string. c++ uses std::string


[after thought]
getline could take a char* now but i dont think it does
First you need to define the size of your text array:
char text[100]; //100 for example

Then you need to cin it like this:
cin.getline(text, 100);
if you are using strings you can use getline(cin,text), but if you use char you should write cin.getline(name, size). Name is the name of the array (text in this case) and size is the max characters that can be read. If you write cin.getline(text, 10), you can enter only 10 characters.
Last edited on
Thanks guys, my program works now
Topic archived. No new replies allowed.