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;
getline(cin,text);
.
.
.
What went wrong, please help
Hello!
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.