I have to input a string into an unsigned short array.
Here is my implementation:
unsigned short strFile [ 200 ] = {0};
cin >> strFile;
I have included the iostream.h header.
But I always get an error:
error C2678: binary ‘>>’ : no operator found which takes a left-hand operand of type ‘std::istream’
Anybody knows how should I solve this?
There is no kind of string that would be compatible with
unsigned short[].There is normal string that is
char [](in C++ you should always keep it instringexcept for constants!) and wide string, that iswchar_t[](in C++ you should always keep it inwstring). And C++11 addschar16_tandchar32_tand their correspondingu16stringandu32string.You can read normal string from normal input stream like
cin. You can read wide string from wide input stream likewcin.wchar_tused to be typedef tounsigned shortin C, but C++ requires it to be a separate type. ISO/IEC14882:2003 3.9.1/5: