T
tvn007
Please help,
basicly, I just want to skip "#" when read line from input file.
Below is my code:
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;
struct Record_info {
string name;
double midterm;
double quiz;
double final;
}student;
int main (void){
double grade;
ifstream in ("test2.txt");
string line,word;
while (getline(in,line)){
if (line.find_first_of("#")) continue; //Just want to skip "#" when
getline
istringstream anyname(line);
anyname>>student.name>>student.midterm>>student.quiz>>student.final;
cout << student.name <<endl;
cout << student.midterm <<endl;
cout << student.quiz <<endl;
cout << student.final <<endl;
}
return 0;
}
//////////// input file: test2.txt /////////
##############
Tony 90.0 -15.2 98.2
Michael 95.0 17.2 92.2
////////////// output from program ////
##############
0
0
0
////////////////// I would like to have the output as follow ???????
Tony
90.0
-15.2
98.2
Michael
95.0
17.2
92.2
basicly, I just want to skip "#" when read line from input file.
Below is my code:
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;
struct Record_info {
string name;
double midterm;
double quiz;
double final;
}student;
int main (void){
double grade;
ifstream in ("test2.txt");
string line,word;
while (getline(in,line)){
if (line.find_first_of("#")) continue; //Just want to skip "#" when
getline
istringstream anyname(line);
anyname>>student.name>>student.midterm>>student.quiz>>student.final;
cout << student.name <<endl;
cout << student.midterm <<endl;
cout << student.quiz <<endl;
cout << student.final <<endl;
}
return 0;
}
//////////// input file: test2.txt /////////
##############
Tony 90.0 -15.2 98.2
Michael 95.0 17.2 92.2
////////////// output from program ////
##############
0
0
0
////////////////// I would like to have the output as follow ???????
Tony
90.0
-15.2
98.2
Michael
95.0
17.2
92.2