#include <iostream>
#include <string>
#include <vector>
usingnamespace std;
main() {
char hoi[500];
int i; // i becomes the size of vector kip
cout << "Hello!" << endl << "type something: ";
cin.getline(hoi,500);
vector<char> kip (hoi, hoi + sizeof(hoi) / sizeof(int) ); // standard coding
for (i=kip.size(); i >= 0; i--) // as long as i isn't less than 0, the vector is printed.
cout << kip[i];
cin.get();
return 0;
}
You can use strlen from <cstring> to give you the length up to (but not including) the null, which marks the end. andm you shouldn't be dividing by sizeof(int), hoi + strlen(hoi) will point to the last letter.
#include <iostream>
#include <string>
#include <vector>
usingnamespace std;
main() {
char hoi[500];
int i; // i becomes the size of vector kip
cout << "Hello!" << endl << "type something: ";
cin.getline(hoi,500);
vector<char> kip (hoi, hoi + strlen(hoi)); // standard coding
for (i=kip.size()-1; i >= 0; i--) // as long as i isn't less than 0, the vector is printed.
cout << kip[i];
cin.get();
return 0;
}