Write your question here.
I need to find the position where enter where pressed to get newline.
and somehow get that position out as an integer and put it in a vector or some sort of container to use later. (insert newlines in some other string).
If anyone can please help.
1 2 3 4 5 6 7
vector<int> space;
int pos;
/*getline to get the input
the input breaks at a empty line*/
for(pos=0;pos<input.size();pos++){
if(input.at(pos)=="\n") space.push_back(pos);
}
what way can this be achieved?
I am confused. not even sure if its possible.
I am trying to write a decipher code.
my code should encrypt the input by the user and return the reversed value.
one part of the code makes the encryption and creates the new string, but that string does not have any new lines. all the inputs comes inside one line.
so i was thinking if i could find the position of the newlines in the input string and just insert a newline in the new string with
string_name.insert(pos_newline,'\n')
I dont know if i should put everything i did. i think that would be alot to look at. ( and also my coding is extremely basic :'/)
The problem is that when you get a string using getline, it does not store the \n character in the string. It just discards it, so you have to add it back yourself if you want to keep it.