#include<iostream>
#include<fstream>
using namespace std;
void main(){
ifstream inf("data.txt");
char name[30];
while(!inf.getline(name, 30, '|').eof())
{
char jersey_number[10];
char best_time[10];
char sport[40];
char high_school[40];
inf.getline(jersey_number, 10, '|');// #read thru pipe
inf.getline(best_time, 10); // #read thru newline
inf.getline(sport, 40, '|'); // #read thru pipe
inf.getline(high_school, 40); // #read thru newline
cout<<"jersey number: "<<jersey_number<<endl;
cout<<"best time: "<<best_time<<endl;
cout<<"sport: "<<sport<<endl;
cout<<"high school: "<<high_school<<endl;
}
Given data file: John|83|52.2
swimming|Jefferson
Jane|26|10.09
sprinting|San Marin
Anyone can explain how the above program work?
i get this from internet source
It will be a great help in doing my assignment.
The problems that avoid me from understanding the syntax
are:
how the getline function that take in 3 arguements
work?
What while(!inf.getline(name, 30, '|').eof()){} actually
do?
Urgent...please help...