I want to read the 3rd line from a text file in as a string
, convert it to a long long int
, and return that value.
The data on the 3rd line of the text file is 1234567890123456
long long int File::Getline3(int user1, int user3)
{
std::string filename = std::to_string(user1);
std::ifstream fin(filename + ".txt");
fin.getline (line1, 5);
fin.getline (line2, 5);
fin.getline (line3, 20);
fin.close();
// convert line 3 to a string called str
const char *line3;
std::string str(line3);
// convert str to long long int called user3
long long int strtoll(const char *nptr, char **endptr, int base);
char* endptr = NULL;
user3 = strtoll(str.c_str(), &endptr, 10);
return user3;
}
The comments are in to show what I think I'm doing, however I am probably wrong (I'm new to pointers).
I get an "unresolved external" error when I try to build my program.