Could someone help me with this?

ifstream readfromfile("stats.txt");

    readfromfile >> lvl >> xp >> str >> spd >> acc >> hp >> endl  >> inventory[0] >> endl  >> inventory[1] >> endl  >> inventory[2] >> endl     >> inventory[3] >> endl  >> inventory[4] >> endl  >> inventory[5] >> endl  >>inventory[6] >> endl  >> inventory[7] >> endl >> equipw >> endl;

The error I get is:

489 C:\Documents and Settings\MixPix\Mina dokument\C++\lvlsystemareas.cpp no match for 'operator>>' in '(+(+(+(+(+((std::basic_istream<char, std::char_traits<char> >*)(&readfromfile))->std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((int&)(&lvl))))->std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((int&)(&xp))))->std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((int&)(&str))))->std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((int&)(&spd))))->std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((int&)(&acc))))->std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((int&)(&hp))) >> std::endl'

Recommended Answers

All 7 Replies

one of your variabes, does not support the >> operator.

Which type are the variables:
lvl
xp
str
spd
acc
hp
inventory?

one of your variabes, does not support the >> operator.

Which type are the variables:
lvl
xp
str
spd
acc
hp
inventory?

lvl - int
xp- int
str- int
spd- int
acc- int
hp - int
inventory - string

odd thing is that this works great when saving the file (this part is the loading function)

did you try without "endl"?

Sounds like an incredibly obvious and easy solution, I shall try that immediately :D

Worked great, thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.