Q:

How to detect a newline in string input in C++

I want to count each newline 
If the input like this:

Hi moon this day I wanna  help

Should be the output like this:

1 Hi moon 2 this day I wanna  3 help
  

I write this code:
int main() {
    string str; int c = 0;
    cin >> str;
    int j = 0;
    string t[200];
    while (str != ";")
    {
        t[j] = str;
        cin >> str;

    }
    for (int i = 0; i < j;i++){
    cout << c << " " << t[j];

    if (t[j] == "\n") c++;
}

    system("Pause");
    return 0;
}

and I was to try :
int c[100];
    cin >> str;
    int j = 0;
    string t[200];
    while (str != ";")
    {
        string temp;
        t[j] = str;
        temp = t[j];
        if (temp.find("\n"))
            c[j] += 1;
        cin >> str;

    }
    for (int i = 0; i < j;i++){
    cout << c[i] << " " << t[j];

}

Can anyone tell to me how to detect a newline in string input and print it? 

A:

Use std::getline to read line by line. Put in a std::vector. Print the vector indexes (plus one) and the strings from the vector.

