the imput file is in c:\\ and its just a notepad file with this info:
Billy Bob 87.50 89 65.75 37 98.50, I want it to output a file with this info but the compiler gives a message about undeclared functions? help
#include %26lt;iostream%26gt;
#include %26lt;fstream%26gt;
#include %26lt;iomanip%26gt;
#include %26lt;string%26gt;
using namespace std;
int main(int argc, char *argv[])
{
ifstream infile;
ofstream outfile;
double test1, test2, test3, tes4, test5;
double average;
string Firstname;
string Lastname;
infile.open("c:\\file.text");
outfile.open("c:\\testavg.out");
outfile %26lt;%26lt; fixed %26lt;%26lt; showpoint;
outfile %26lt;%26lt; setprecision(2);
cout %26lt;%26lt; "Procesing data" %26lt;%26lt; endl;
infile %26gt;%26gt; Firstname %26gt;%26gt; Lastname;
outfile %26lt;%26lt; " Students name: " %26lt;%26lt; Firstname %26lt;%26lt; " " %26lt;%26lt; Lastname %26lt;%26lt; endl;
infile %26gt;%26gt; test1 %26gt;%26gt; test2 %26gt;%26gt; test3 %26gt;%26gt; test4 %26gt;%26gt; test5;
outfile %26lt;%26lt; "Test scores: " %26lt;%26lt; setw(6) %26lt;%26lt; test1
%26lt;%26lt; setw(6) %26lt;%26lt; test2 %26lt;%26lt; setw(6) %26lt;%26lt; test3
%26lt;%26lt; setw(6) %26lt;%26lt; test4 %26lt;%26lt; setw(6) %26lt;%26lt; test5 %26lt;%26lt; endl;
average = (test1 + test2 + test3 + test4 + test5) / 5.0;
outfile %26lt;%26lt; "Average test score: " %26lt;%26lt; setw(6) %26lt;%26lt; average %26lt;%26lt; endl;
infile.close();
outfile.close();
return 0;
}
Need help with a c++ Code?
It's just a typo:
Your declaration statement is:
double test1, test2, test3, tes4, test5;
Here you have declared a variable as "tes4"(you forgot "t", it should be test4) :)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment