0
anyone who could give me more info and explain the parameters of the function strtoull?
#include <iostream> #include <stdlib.h> using namespace std; //also I have no idea about the c_str() part int main() { string n; cin>>n; cout<<strtoull(n.c_str(),NULL,2); return 0; }
2 Réponses
+ 1
A purpose of function strtoull is convert a string into unsigned long long int type value. This function needs a C-string type (declared as char *) first parameter. When want to use it with a object string (declared as string n) you have to convert it into C-string. So, the parameters of calling the function strtoull here in code : strtoull(n.c_str(),NULL,2) are:
n.c_str() converts your string into C-string
NULL-read the number to end of string
2 - base of number in string. Just for right parsing. So here 2 means a binary base. Only 0 and 1 are allowed
0
thank you, it really helped me