Hello,
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
while (!file.eof())
{
getline (file, abc);
checkfile.append (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))
{
checkfile.append (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++ 4.9.9.2 is handy to have as my ancient Windows 95 PC has the same version on it. But thanks for the code, worked perfectly!
Well, I do agree it can be useful to have the same software on each computer.
Anyway, there's a choice of compiler with the Orwell version, both 32 and 64 bit versions are available.
As for it crashing, that's unfortunate, I suggest you try it again soon, as new versions are made available very regularly.