I am trying to take two strings as input and combine them and all their individual character into a vector.
Full Code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
string str1;
string str2;
cin>>str1>>str2;
vector<char>vec;
for(int i=0;i<str1.length();i++){
vec[i]=str1[i];
}
int k=str1.length();
for(int i=0;i<str2.length();i++){
vec[k]=str2[i];
k++;
}
for(int i=0;i<vec.size();i++){
cout<<vec[i];
}
}
What am I missing? Am I missing a concept about strings here?
I am trying to take two strings as input and combine them and all their individual character into a vector.
In terminal code shows no error, takes input for both strings, but shows no output.