' delimiters. Right now I am populating the entire file into the first element of the array. I would like each string to populate the next array element.

问题描述 投票:0回答:1
contains the entire file, while

is empty. here is what the

ifstream infile;
infile.open("info.dat");
string line;
int counter = 0;
while (getline(infile, line))
{
    getline(infile ,line ,'|');
    b[counter] = line;
    counter++;
    cout << endl;
}
infile.close();

cout << b[0] << endl << b[1];
return 0;
}

b[0] file contains.b[1]I am trying to use the b[] array to separate the strings. in my .dat at the bottom I was expecting "green dog" to print on the first line and "red fish" to print on the second line of the console.

green dog|red fish|brass monkey|purpe elephant||||||||||||

cout

I am trying to populate a string array from a text file that has '
c++ arrays delimiter
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.