char *vname = (char*)malloc(vertexNum*sizeof(char));//这里把string改为char试试 for (int i=0 ;i { cout << " 请输入编号为" << i << "的景点名称:"; getline(cin , vname[i]); }