File Processing in C++ issues -


i'm doing project file processing in c++. project wants users create sequential file (input data), , file reading data sequential file (output data). i'm using visual studio write program. came few problems.

  1. visual studio has 1 int main() in 1 project. how can write program? did same project java , works fine.

  2. i tried create separated project. now, can have 2 int main() can not read data first file (input), because 2 different projects.

i'm new c++ , hoping guys can me. not know if can post question here. thank much!

updated

input

 #include <iostream>     #include <fstream>     #include <string>     #include <cstdlib>     using namespace std;      int main()     {         ofstream outclientfile("payroll.txt", ios::out);          if (!outclientfile)         {             cerr << "file not opened" << endl;             exit(exit_failure);         }          cout << "enter employee id, hours , payrate" << endl             << "enter end-of-file end input.\n? ";          int id;         float hours;         float payrate;          while (cin >> id >> hours >> payrate)         {             outclientfile << id << ' ' << hours << ' ' << payrate << endl;             cout << "? ";         }     } 

output

#include <iostream> #include <fstream> #include <iomanip> #include <string> #include <cstdlib> using namespace std;  void outputline(int, float, float, float);  int main() {     ifstream inclientfile("payroll.txt", ios::in);      if (!inclientfile)     {         cerr << "file not opened" << endl;         exit(exit_failure);     }      int id;     float hours;     float payrate;     float grosspay = hours * payrate;      cout << left << setw(10) << "employee id" << setw(13) << "hours" << "payrate" << setw(10) << "grosspay" << endl << fixed << showpoint;      while (inclientfile >> id >> hours >> payrate >> grosspay)         outputline(id, hours, payrate, grosspay); } void outputline(int id, float hours, float payrate, float grosspay) {     cout << left << setw(10) << id << setw(13) << hours << setw(7) << payrate << setw(7) << setprecision(2) << right << payrate << endl; } 

you don't need have more 1 main function.

you can make part1 function , part2 function , call them both main 1 after another.

void part1(){ //code writing file }  void part2(){ //code reading file }  int main(){     part1();     part2();     return 0; }