I need to know if I'm on the right track for this program problem
Write a program that reads the attached text file. Each record in the file contains a name. You are to create an output file named names.csv. csv is the file extension for a comma delimited file. You are to create the csv file in such a way that the names in the input file wind up in columns rather than rows when you open the file in Excel. Let me know what I need to do to make this work or let me know if I'm on the right track.
Thank you, Joel
Jane
Peter
Joe
Ann
Source code
#include<fstream.h>
#include<iostream.h>
#include<stdlib.h>
int main ()
{
ifstream in_stream;
ofstream out_stream;
cout << "Edit files.\n";
//open input file. If the file cannot be opened. Print fail statement and end.
in_stream.open("namesin.txt");
if(in_stream.fail())
{
cout <<"Input file opening failed.\n";
exit(1);
}
// Open output file. If the file cannot be opened. Print fail statement and end.
out_stream.open("names.csv");
if(out_stream.fail())
{
cout <<"Output file opening failed.\n";
exit(1);
}
char name[4];
while(!in_stream.eof())
{
in_stream >> name;
out_stream <<(name)<<"," <<endl;
}
in_stream.close();
out_stream.close();
cout << "End of files.\n";
getchar();
return 0;
}