I am running a simple C++ program (Visual Studio 2017) that requires user input.
This is how I collect that input:
int main()
{
char* in;
in = '\0';
std::cout << "Move?\n";
std::cin >> *in;
}
However, an exception is thrown on the last line:
Exception thrown: write access violation.
**_Ch** was nullptr.
When I take a closer look, the error is thrown from within the istream
class at line 910
:
template<class _Elem,
...
if (_Ok)
{ ...
if (_Traits::eq_int_type(_Traits::eof(), _Meta))
_State |= ios_base::eofbit | ios_base::failbit;
else
_Ch = _Traits::to_char_type(_Meta); // ERROR THROWN HERE
What am I doing wrong?