So I was running a simple C++ code containing this piece
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
for(int k=i;k--;k>=1)
{
if(outgoing[k]=='Y' && incoming[k-1]=='Y')
result[i][k-1]='Y';
else
break;
}
So usually the error if there is any it printed into console output but while running this code it printed this error inside the output file
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libstdc++-v3/include/bits/basic_string.h:1067:
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference
std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::operator[](std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>;
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference =
char&; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type
= unsigned int]: Assertion '__pos <= size()' failed.
I don't understand why? And who is Keith?
I know the error by the way here
for(int k=i;k--;k>=1)
k-- and k>=1 should be swapped