C++输入含有空格的字符串,字符串存储在数组的第一个元素

现在VS中已经禁用了gets函数,cin读取是一个元素一个元素的存放,而fgets和getline和scanf_s有字符限制。
求一个没有字符限制的,可以输入字符串并存储给数组单个元素的方法,谢谢。

用getline,数组定义成string就行了。

#include<iostream>
#include<string>
using namespace std;
int main()
{
    const int size = 2;
    string *s = new string[size];
    for (size_t i = 0; i < size; i++)
    {
        getline(cin, s[i]);
        cout << endl;
    }
    for (size_t i = 0; i < size; i++)
    {
        cout << s[i];
        cout << endl;
    }
    delete[]s;
    return 0;
}

scanf