Hi. I'm new here and would appreciate any help you can give me.
I am a college student and I'm supposed to do this assignment where I take data from one txt file and put it into another. This is step one of a larger project. I have some code done but it's not that good. The infile is data for grocery receipt tape with five pieces of data across it. I have the outfile creating itself but it only contains zero's- three of them for each variable I created? How do I specify what to read from the infile? I need to read the first three of the five items. Thanks!
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int item_number, item_name, unit_price; //declaring variables
int main()
{
ifstream indata;
indata.open("data.txt",ios::in); // opens the infile
ofstream outdata;
outdata.open("YourLastName_YourFirstName.txt",ios::out); //opens the outfile
outdata<<item_number<<item_name<<unit_price;
indata.close (); //closes the infile
outdata.close (); // closes the outfile
return 0;
}