C++ 将字符串从向量复制到字符串 #包括 #包括 #包括 #包括 #包括 使用名称空间std; int main(int argc,char*argv[]) { 字符串s; 字符串s1; 矢量图像; 不能
只使用赋值:C++ 将字符串从向量复制到字符串 #包括 #包括 #包括 #包括 #包括 使用名称空间std; int main(int argc,char*argv[]) { 字符串s; 字符串s1; 矢量图像; 不能,c++,C++,只使用赋值: #include <iostream> #include <fstream> #include <string> #include <stdlib.h> #include <vector> using namespace std; int main(int argc, char *argv[]) { string s; string s1; vector<string> images
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
string s;
string s1;
vector<string> images;
cout<<"enter the names";
for (int i=0;i<5;i++)
{
cin>>s;
images.push_back(s);
}
for(unsigned int i=0;i<images.size();i++)
{
cout<<images.at(i)<<endl;
strcpy(s1,images.at(i));
cout<<s1;
}
}
请注意,在您的代码示例中,没有理由复制该字符串。为什么要复制该字符串?我现在正在学习教程,我想将标签从as name of the user prediction=6 as prediction=john更改为as name of the user prediction=6 as prediction=john如何执行此操作
s1 = images.at(i);