我被告知你必须使用gets(str)来输入字符串而不是cin。不过我可以cin在下面的程序中很好地使用。有人可以告诉我是否可以使用cin吗?对不起,我的英语不好。该程序允许您插入 5 个姓名,然后将这些姓名打印到屏幕上。
这是代码:
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char **p = new char *[5];
for (int i = 0; i < 5; i++)
{
*(p + i) = new char[255];
} //make a 2 dimensional array of strings
for (int i = 0; i < n; i++)
{
char n[255] = "";
cout << "insert names: ";
cin >> n; //how i can use cin here …Run Code Online (Sandbox Code Playgroud)