How to identify a new line in C++?

前端 未结 4 660
猫巷女王i
猫巷女王i 2021-01-25 05:14

I have to take integer input to an integer array. I have to identify the newline also in input. To be more clear, I have an example. The input I am giving is:-

2         


        
4条回答
  •  离开以前
    2021-01-25 05:41

    int array[42];
    int* ptr = array;
    for (string line; getline(cin, line); ) {
        istringstream stream(line);
        stream >> *ptr++;
    }
    

    Error checking elided.

提交回复
热议问题