As i was trying to find gcd of large numbers in which one number is 10^250 and other is like between 100000. While trying to do that in c++ am getting one error which i am not able to figure out but same code in python3 works fine.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll gcd(ll n,ll mod)
{
if(!n)
return mod;
return (mod%n,n);
}
ll getmod(ll n,char b[])
{
ll mod = 0;
for(int i =0;i<strlen(b);i++)
{
mod = mod * 10 + b[i];
mod %= n;
}
return mod;
}
int main() {
// your code goes here
ll n;
string m;
cin>>n;
getline(cin, m);
int mod = getmod(n,m);
int result = gcd(n,mod);
cout<<result;
return 0;
}
Output
prog.cpp: In function 'int main()':
prog.cpp:26:22: error: cannot convert 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'char*' for argument '2' to 'll getmod(ll, char*)'
int mod = getmod(n,m);
^