|
-
March 28th, 2010, 09:31 AM
#1
Selfappending vector
Hello,
I've got a strange problem:
#include <vector>
#include <iostream>
#include <string>
int main(){
std::vector<std::string> strvec;
strvec.push_back("A");
strvec.push_back("B");
strvec.push_back("C");
strvec.push_back("D");
strvec.push_back("E");
std::vector<std::string>::size_type i = strvec.size()-1;
for(;i>0;--i)
strvec.push_back(strvec[i-1]);
for each(std::string str in strvec)
std::cout << str << ',';
return 0;
}
Gives me;
A,B,C,D,E,D,,B,A
What am I doing wrong?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|