Answer the question
In order to leave comments, you need to log in
Reading from a file up to a certain point, how to implement it?
I have a txt file
with the following text:
1 0 Bur
1 1 Burn
1 2 Kanav
1 3 Mos
0 3 Strel
1 4 Gork
2 3 Chkal
3 3 Lenins
4 3 Zarec
5 3 DvR
6 3 Prol
7 3 Avtoz
8 3 Kom
8 4 Kirov
8 5 ParkK
void tracePath(cell cellDetails[][COL], Pair dest)
{
printf ("\n Marshrut: ");
int row = dest.first;
int col = dest.second;
stack <Pair> Path;
while (!(cellDetails[row][col].parent_i == row && cellDetails [row][col].parent_j == col))
{
Path.push(make_pair (row, col));
int temp_row = cellDetails [row][col].parent_i;
int temp_col = cellDetails [row][col].parent_j;
row = temp_row;
col = temp_col;
}
Path.push(make_pair(row,col));
while (!Path.empty())
{
pair<int, int> p = Path.top();
Path.pop();
//
if (p.first == 2 && p.second == 0)
{
printf("-> Burevestnik ");
}
else
{
printf("-> (%d,%d) ",p.first,p.second);
}
}
return;
}
Answer the question
In order to leave comments, you need to log in
That's the easiest way
std::string buf;
std::ifstream file("my.txt");
while(std::getline(file, buf)) {
if(buf == "STOP") {
break;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question