Namespaces
At least in my experience, dislike for the std::
prefix all over the place is largely a matter of what you're accustomed to seeing. When namespaces were new, I found it quite jarring and off-putting. 20 years (or so) later, I generally prefer code that includes it (though some might argue that this is just a strange case of Stockholm syndrome).
In this case, if you really prefer to avoid the std::
all over the place, you could put the namespace directive inside of main
, to get something like this:
int main()
{
using namespace std;
string text;
vector<string> svec;
while (cin >> text)
svec.push_back(text);
for (vector<string>::size_type i = 0; i < svec.size(); i++)
cout << svec[i] + " " << svec[i].size() << "\n";
return 0;
}
If you prefer that, I doubt that anybody's likely to object too strongly to a namespace directive whose scope is limited to a single function.
Algorithms
Regardless of how you choose to deal with the namespace issue, I'd at least consider using a standard algorithm instead of writing explicit loops yourself.
In addition, your code isn't particularly efficient in its use of memory--its basically "parking" data in the vector for no particular reason. That is, it copies data from input to the vector, then from the vector to output, but never does anything with it in between that requires that the strings be stored.
That being the case, I'd avoid storing more data than necessary, and I'd use a standard algorithm to do the work.
#include <algorithm>
#include <string>
#include <iostream>
#include <iterator>
int main(int argc, char const *argv[])
{
using namespace std;
istream_iterator<string> in{ cin }, end;
transform(in, end, ostream_iterator<string>(cout, "\n"),
[](string const &s) { return s + ' ' + to_string(s.length()); });
}