麻烦与矢量编码支付名称
Trouble dispaying names with Vector coding
下午好.....我目前是一名学生在C++课程,我们正在为向量编写代码。在作业中,我们必须显示3个学生的名字。当我在以下代码运行后添加名称时,它只显示向量的数量而不是名称(这是必需的)。感谢您的帮助。
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
using std::cout;
using std::cin;
using namespace std;
int main()
{
bool running = true;
char choice;
vector <string> studentVector;
cout << "My Student Vector" << endl;
while (running == true)
{
cout << "Choose a Selection: [A]dd Student, [V]iew Student, [R]emove Student, [E]xit" << endl;
cin >> choice;
cin.ignore();
if (choice == 'A' || choice == 'a')
{
cout << "Enter Student's Name: ";
string tempVar;
getline(cin, tempVar);
studentVector.push_back(tempVar);
}
else if (choice == 'V' || choice == 'v')
{
cout << "You have " << studentVector.size() << "Student(s)." << endl;
for (int i = 0; i << studentVector.size(); i++)
{
cout << i << ". " << studentVector.at(i) << endl;
}
}
else if (choice == 'R' || choice == 'r')
{
int pos;
cout << "Enter the vector position for the student in question: ";
cin >> pos;
cin.ignore();
studentVector.erase(studentVector.begin() + pos);
}
else if (choice == 'E' || choice == 'e')
{
running = false;
}
else
{
cout << "Invalid Selection" << endl;
}
}
在显示名称的for
循环中,您真的是指i << studentVector.size()
吗?
相关文章:
- 如何确定我已使用非编码文件到达 EOF?
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 在卡萨布兰卡形成编码参数的列表
- 使用C++进行游程编码
- 如何将不同的可执行文件合并到一个窗口框架中进行编码?像浏览器一样
- 使用已使用 java 编码的 openssl 解码数据
- boost 是否有按特殊类型值编码状态"compact optional"?
- 如何在CPP的给定目录中列出UTF编码的文件名?
- 如何使用 C++将 ISO-2022-KR 编码转换为 UTF-8 编码?
- 我已经阅读了很多关于 2d 数组的信息,但我在作业中使用它时遇到了麻烦
- 绝对编码器十六进制输入
- 查找奇数平方和时遇到麻烦
- 防止C++中的硬编码数字
- 将C++ std::string 转换为 UTF-16-LE 编码的字符串
- 使用文件内容作为硬编码字符串
- 运行长度编码程序 c++ 的问题
- 以C++为单位进行运行长度编码
- *新的编码器*格式和运算符
- 在初学者编码挑战中麻烦
- 麻烦与矢量编码支付名称