•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 401,657 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,684 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 2419 | Replies: 2
![]() |
•
•
Join Date: Jan 2005
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Hi, I'm having trouble on transfering "input.txt" over to "output.txt" what command shall I use with C++ language? Anyways below is the question I needed to answer on monday, anyway help will be very very appreciated.
write a program to compute numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's last name, then on espace, then the student's first name, then one space, then ten quiz scores all on one line. The quiz scores are whole numbers and are separated by one space. Your program will take its input from this file and send its output to a second file. The data in the output file will be the same as the data in the input file except that there will be one additional number ( of type double ) at the end of each line. This number will be the average of the student's ten quiz scores. If this is being done as a class assignment, obtain the file names from your instructor. Use at least one function that has file streams as all or some of its arguments.
write a program to compute numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's last name, then on espace, then the student's first name, then one space, then ten quiz scores all on one line. The quiz scores are whole numbers and are separated by one space. Your program will take its input from this file and send its output to a second file. The data in the output file will be the same as the data in the input file except that there will be one additional number ( of type double ) at the end of each line. This number will be the average of the student's ten quiz scores. If this is being done as a class assignment, obtain the file names from your instructor. Use at least one function that has file streams as all or some of its arguments.
•
•
Join Date: Jan 2005
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
nm I know how to transfer files from input to output now.. but i'm still having problem output the average of every line from input file.. how is it being done? my codes are below
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
void copy(ifstream& in_stream, ofstream& out_stream);
int main( )
{
ifstream fin;
ofstream fout;
cout << "Begin editing files.\n";
fin.open("input.txt");
if (fin.fail( ))
{
cout << "Input file opening failed.\n";
exit(1);
}
fout.open("output.txt");
if (fout.fail( ))
{
cout << "Output file opening failed.\n";
exit(1);
}
copy(fin, fout);
fin.close( );
fout.close( );
cout << "End of editing files.\n";
return 0;
}
void copy(ifstream& in_stream, ofstream& out_stream)
{
char next;
in_stream.get(next);
while (! in_stream.eof( ))
{
out_stream << next;
in_stream.get(next);
}
}![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Setting an array and reading in a txt file backwards (C++)
- get the coordenates of a word in a puzzle (C)
- A small problem in the output (C++)
- Need help to edit fin & fout files output (C++)
- run program and rename file script help please (Shell Scripting)
- Getting all data from an input and output file (C++)
Other Threads in the C++ Forum
- Previous Thread: Access Violation (Segmentation Fault) + atol
- Next Thread: help with inserting a number into an array


Linear Mode