Ok, the thing is, I have no idea how to do it legitimately with strings, cin etc., so I did it in twisted way.. the problem is I have to enter the word twice, I have no idea why.
For example, I enter
Name, press enter, then I have to enter the same or different name again and it will automatically press enter after there are the same amount of characters as in the first name.. so I would try to enter
Cupcakes for the second time, but after fourth character,
c, the loop will be stopped and it will give me
cpuC as a result.
The thing is I don't want to type second time. If it's impossible to change that I would, at least, like program to say something like "
Now enter the name second time, for fun". Thanks.
1 2 3 4 5 6 7 8 9 10
|
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
char j[1000];
int n=0;
while (cin.get() != '\n'){j[n]= _getch(); cout << j[n]; n++;}
while (n>=0) {cout << j[n]; n--;}
}
|