I have been having a problem coding up a program for security, just to test.
this error has been coming up:
main.cpp could not convert `(&checkfile)->std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)(&lok))))' to `bool'
Two errors here: if (checkfile=lok);
a) the comparison operator == should be used, rather than the assignment operator =
b) the line should not end with a semicolon.
This code is not recommended:
1 2 3 4 5
getline (file, abc);
because even if the getline at line 3 fails, the next line is still executed.
This would be the safer way:
1 2 3 4
while (getline (file, abc))
One more thing, the version of Dev-C++ you are using is very old, if I remember correctly it was last updated in 2005. I would strongly recommend you upgrade to the latest version, Orwell Dev-C++ 5.4.1 http://orwelldevcpp.blogspot.co.uk/
Thanks Chervil, BTW i used to have orwell Dev-C++ but it crashed and had mingw64 where mine is mingw32. And Dev-C++ 184.108.40.206 is handy to have as my ancient Windows 95 PC has the same version on it. But thanks for the code, worked perfectly!