cin not ending

Hello i'm quite new to c++ and have written a simple program that will decipher some text based on a transposition cipher. However my problem is that cin takes the input and stores it into a char array but when i press enter on my keyboard it does not move onto the next piece of code in the program it just continues to take input at console. any help would be greatly appreciated its been racking my brain!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Decipher program by JM
#include <iostream>
using namespace std;

int main ()
{
	cout << "Please enter the ciphertext and press enter: \n";		//display message to user

	char plainText[100];
	char inputArrayy[100];
	int p = 0;

  while(cin >> inputArrayy[p]) {
	  p++;
  }

int n = 0;
int i = 0;

while (sizeof(inputArrayy)/sizeof(inputArrayy[0]) != sizeof(plainText)/sizeof(plainText[0])){		


	while (inputArrayy[n] == '*'){			
	n++;									
	}

	plainText[i] = inputArrayy[n];			
	inputArrayy[n] = '*';					

	n = n+3%(sizeof(inputArrayy)/sizeof(inputArrayy[0]));			

	i++;															
}

cout << plainText;													

return 0;

}



Last edited on
In Window use F6 or ctrl-Z.
Or in Unix use ctrl-D
using F6 or ctrl-Z just produces ^Z characters in the console window. using win xp by the way.
It signals end of file for stdin, which is what you want, right?
yeah thats what i want, but it doesnt seem to work. The while loop just keeps looping, i think i'm going to have to take input and store it as a string, then convert that to a char array. now i just need to find out how to do that...lol
I just tested it. It works. ^Z or F6 followed by <enter>
Topic archived. No new replies allowed.