qfegd wrote:
In those situation stringstream can be cool!
and (IMHO) utterly superfluous... there is already and input stream open in the form of the input file stream why read a line convert it to another input stream and then use operator>> on that stream:confused: as the input text file is rigorously defined why not use >> directly on the input file stream? operator>> is overloaded for the inbuilt types & defaults to consuming white space and newlines (thanks Bjarne) thus... char n1[255]; char n2[255]; double total, mean, grade; int count = 10; //specified in the input file format ifstream in_file(IN_NAME); //checking omit'd for clarity while(!in_file.eof()) { in_file >> n1 >> n2; total = 0.0; for(int i = 0, i < count, ++i) { in_file >> grade; total += grade; } mean = total / count; } i will leave writing to the output file for you (it can all be fitted into the above loop in 3 lines) if your input file might be dirty you could add in_file.ignore(255,'\n'); to ignore upto 255 characters at the end of the line and any new line. hope this helps? :)