#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string filename,inputfilename, outputfilename;
char *mode = "r";
ifstream inputfile;
while(!inputfile.is_open()) {
cout << "Input filename: ";
getline (cin, inputfilename);
ofstream outputfile;
while(!outputfile.is_open()) {
cout << "Output filename: ";
getline (cin, outputfilename);
char username[20]; /* Username input */
int score;
int score2; int score3; int score4; int score5; int score6;
inputfile.open(inputfilename.c_str(),ios::in | ios::binary);
outputfile.open(outputfilename.c_str(),ios::out | ios::binary);
while cout << "%s %d %d %d %d %d %d", username, &score, &score2, &score3, &score4, &score5, &score6) == 7) {
fprintf(outputfilename, "%s %1.2d \n", username, (score + score2 + score3 + score4 + score5 + score6)/6);
}
getch();
return 0;
}
}}
I had origninally buildt this in *FILE but needed to edit it to fit ifstream so how do i fix these files w/ compiling errors?
while cout << "%s %d %d %d %d %d %d", username, &score, &score2, &score3, &score4, &score5, &score6) == 7) {
fprintf(outputfilename, "%s %1.2d \n", username, (score + score2 + score3 + score4 + score5 + score6)/6);
}
changed to this while (fscanf(inputfilename, "%s %d %d %d %d %d %d", username, &score, &score2, &score3, &score4, &score5, &score6) == 7) {
fprintf(outputfilename, "%s %1.2d \n", username, (score + score2 + score3 + score4 + score5 + score6)/6);
}
this code is written horribly. you need to use code blocks and clean up the code and pick if you want to write in c or c++ because you are doing both
Last edited on
if you are making fun of me catfish let me rephrase use c++ syntax