Here is the code with the changes as compared to the original in the first post.
Code:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> vec;
vec.push_back("test");
string c;//added
string s(vec[0]);
c( s.size(), char() );//deleted std::string
cout << c << endl;
copy( s.begin(), s.end(), c.begin() );
cout << c << endl;
return 0;
}
Code:
string_copy1.cpp: In function int main():
string_copy1.cpp:13: error: no match for call to (std::string) (size_t, char)
Also, If I change some of the code to the following:
Code:
std::string c( s.size(), char() );
for(int i = 0; i < c.size(); i++)
cout << c[i];
cout << endl << c.size();
I find that, cout << c[i];, produces all spaces yet c.size() prints out the number 4. Is c( s.size(), char() ) an integer? I hope I've explained this well enough. I am really confused on this.