I think for long long int
it should not be atoi
, but strtoll
:
long long int strtoll(const char *nptr, char **endptr, int base);
supposingly line3
is a string, you might use it as:
char* endptr = NULL;
user3 = strtoll(line3.c_str(), &endptr, 10);
and sice you marked it as c++
you also can use: http://www.cplusplus.com/reference/string/stoll/
edit after your comment: strtoll
takes a const char*
and converts its content into a long long int
. If endptr is not NULL
, strtoll()
stores the address of the first invalid character in *endptr
. You also can specify the base
for the number.
You did (atoi(line3));
but atoi
also expects a const char*
so I supposed that line3
must be a std::string
(due to the way you use it) that's why I gave a shot in the dark with the c_str()
to get the actual data of the string, instead of the object itself..
Instead of atoi
you can use of course atoll
for long long stuff :)