I am pretty new to coding and encountered the following error.
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::at: __n (which is 6) >= this->size() (which is 6)
Aborted (core dumped)
The code for the following was:
#include <iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
string sa=to_string(a);
string sb=to_string(b);
int l=sa.length();
for(int i=0;i<l;i++)
{
if(sa.at(i)==sb.at(i))
{
cout<<0;
}
else
cout<<1;
}
}
The input for this problem was
1010100
0100101
Any help regarding this will be appreciated!