Code works fine on my machine whereas it shows this error in the editor online

/bin/run.sh: line 4: 18 Bus error (core dumped) ./exe

code
#include
#include
#define ll long long
using namespace std;
int main()
{
ll int n;
cin>>n;
ll int val =n;
int digit;
while(val)
{ digit++;
val/=10;
}
val = n;
int arr[digit];
for(int i =0;i<digit;i++)
{
arr[i] = val%10;
val/=10;
}
ll int sum =0;
for(int i=0;i<digit;i++)
{
sum += pow(arr[i], digit);
}
if(sum == n)
{
cout<<“true”;
}
else
cout<<“false”;

return 0;
}

hello @laksh.rustagi12
pls save ur code at cb ide and share its link with me

check now->

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.