anyone who could give me more info and explain the parameters of the function strtoull? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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; }

17th Dec 2016, 2:53 PM
Catalin Dervesteanu
Catalin Dervesteanu - avatar
2 Answers
+ 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
17th Dec 2016, 5:28 PM
Petr Hatina
Petr Hatina - avatar
0
thank you, it really helped me
17th Dec 2016, 5:34 PM
Catalin Dervesteanu
Catalin Dervesteanu - avatar