Hello All,
I am a noob in c++ and i was trying to code a program where i can get some data from a input file and then create an out put file.
My input file looks somthing like this -
21 32
33 02
76 48
Now i have to read these lines using the get command, and then multply them and store them in z , so that my output looks like
21 32 672
i am having trouble with my code. I am posting it below any comments and help would be appreciated.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cmath>
using namespace std;
// Main Program
void main()
{ string fname,outfname;
fstream infile,outfile;
int z,count;
// Initialize Count
count = 0;
// User Input
cout << " XZY Multiply Program " << endl;
cout << "Enter File Name: ";
cin >> fname;
infile.open(fname.data(),ios::in);
if (!infile.is_open()) return; // Input File
z is an integer how can it have that value?
Anyway I already stated that you never give a value to z in your program. After reading x and y you should set z to x*y.