I hope anyone will be able to help me out, or at least understand what i am trying to achieve. i tried searching for this all over the web and i did not find the answer, or at least did not understand what others did.
So, im trying to read each line from file.txt into a array. As an example, my file.txt contains:
3
labas
ka tu
nu tai davai
(Just an example)
I want to get each line into my
string sentenses[CMax];
(CMax is set to 10000)
After hours of searching the web and tinkering myself i ended up with:
ifstream KC;
KC.open(langPicked.c_str());
KC >> m;
for (int o = 0; o < m; o++) {
KC.getline(sentenses[o], 255);
if(KC) cout << sentenses[o] << endl;
}
KC.close();
But, surprise surprise, it aint working.
Basickly what i am trying to achieve is that each line, from KC, would be added to >> sentenses[o] array so i could cout what ever line i wish so, as an example, if i typed:
cout << sentenses[2] << endl;
it would output the 2 line:
ka tu
error that pops up:
D:\Lith\Codeblocks\uzd\Skaiciuokle 2.0\main.cpp|88|error: no matching function for call to 'std::basic_ifstream::getline(std::__cxx11::string&, int)'|
NOTE: The code that i posted might, and propobly is, in some way, shape or form wrong. I am just a started trying to learn c++ on my own. If you understood what i was trying to do, feel free to answer with your own written code that would fit in my situation. Thank you in advance