Why do I have to press the carriage return twice here

Why do I have to press the carriage return twice here? Specifically after line 10?
edit:
I have to press the enter key/return twice before the for loop aft line 10 will execute.

Not sure if this is my ide or not?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

using namespace std;

int main(int argc, const char * argv[])
{

    char charArr[50];
    cout << "Please enter in a string";
    cin.getline (charArr,'\n');

    char * c = NULL;
    for (c = charArr; *c != '\0'; c++) {
        cout << *c << endl;
    }
    return 0;
}
Last edited on
It works fine for me.
i have Visual C++ 2008 Express edition.
This is the output I am seeing:

Please enter in a stringhello
h
e
l
l
o
Press any key to continue . . .
Topic archived. No new replies allowed.