我目前正在学习C++,我想手动将值输入到字符串向量中,在存储之前处理每个字符.这是我使用的代码:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int i, height = 5, width = 5;
vector<string> lab;
lab.resize(height, "");
string s;
//For input reference
cout << endl << "Input data:" << endl << "01234" << endl;
//Input values
for (i = 0; i < height; i++)
{
getline (cin, s);
for (int j = 0; j < width; j++)
{
//Process char [...]
lab[i][j] = s.at(j);
}
}
//Show Matrix
cout << endl << …Run Code Online (Sandbox Code Playgroud)