Hello,
I'm learning C++ and i want to know how i can develop a program that reads a file like a database, but the program don't know how many lines or columns the file have, and the file is like this:

"Name Test" "1901" "email@test.com"
"John Google" "6673" "john@test.com"

And how i can remove the quotes automatically, remember that this is a test file, the program have to read more lines or not and the program don't know how many lines and columns are, this is my difficult.

Thanks,
Nathan Paulino Campos

Suggest you use getline() to read the entire line, then use stringstream object to split it into words.

std::string line;
ifstream in("file.txt");
while( getline( in, line) )
{
     std::string word;
    stringstream str(line);
    while( str >> word )
    {
       // now do something with this word
    }
    
}

As for the quotes -- you will have to parse the word and strip them out if they exist.

Thanks very much, +1 of reputation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.