I'm going to try not to do your homework for you and at the same time help you out.
do some homework on fstream/iostream/ and common string functions like atof()
all file input/output will be in TEXT format. not Binary
Code:
input file.
... abcdefghijklmnopqrstuvwxyz
... 10
... 20
... 30
include <fstream>
include <iostream>
int main(){
char* p;
float number_1; // i'm using float to make you do some research.
float number_2;
float number_3;
float number_4;
std::fstream inputfile;
file.open("myfile.txt", std::ios::in);
//refer to other parts of this site for error checking.
//first lets get some room to work.... by that i mean storage space.
p = new char[100];
//error checking again
memset(p,0,100); //clear the work space;
inputfile.read( p ); //<< more homework here.
//now your buffer p should contain your entire text file.
//TIP 1: the lines in the file will be sepraerated by '\n' and not \0
//now lets read the first line.
magical_function_you_need_to_write_to_find_where_newline_is( p );
//Image we have another file called outputfile
outputfile.write(p, magical_function_return_value());
file.getline(p, 100);
//please note the above function.
//anyway enought TIPS 2:
//Now we just got the numbers.
number_1 = atof(p);
file.getline(p, 100);
number_2 = atof(p);
file.getline(p, 100);
number_3 = atof(p);
if( (number_1 + number_2) != number_3)
exit(1)//10+20 != 30 then something is wrong. but i am using float's. hehehe
std::cout "The sum of \"" << number_1 << "\" and \"" << number_2 " = \"" << number_3;
hope this helps. but as they said eariler the porblem is perty much self explanitory(forgive my spelling.)
basicly the excersize is to get you familer with file input/output and get you using the std libary. after you learn how to get JUST what you want out of a file you can start learning the printf and _snprintf() functions.