0

Write a program that will read the file, Address.txt, which I have provided. It contains names and numbers with no spaces between. Write the same data to a new file with the numbers right justified in 12 spaces and with 3 decimals.

(file):
Pete Moss25.33
Sara Bellum78.45
Harry Legg 76
Les Ismoore34.5
April Showers109
June Meadows87.345
Mae Flowers68.5
Guy Wire56
Chris Craft66.335
Slim Pickens115.25

4
Contributors
4
Replies
5
Views
13 Years
Discussion Span
Last Post by alc6379
0

this is what i have so far no working too well

Attachments
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;

int main()
{
	ifstream fin;
	ofstream fout;
	char file[12], ofile[12], letter;

	cout << "What is the name of your address input file?";
	cin >> file;

	cout << "What is the name of your address output file?";
	cin >> ofile;

	fin.open(file);
	fout.open(ofile);

	if(fin.fail())
	{
		cout << "Opening of the input .dat file failed\n";
		exit(1);
	}
	if(fout.fail())
	{
		cout << "Opening of the output .dat file failed\n";
		exit(1);
	}
	fin.get(letter);
	do
	{
		fin.get(letter);
		if(isalpha(letter))
		{
			fout << letter;
		}
		else
		{
			fin.putback(letter);
			fout << setw(12);
			while(!fin.eof());
			{
				fout << letter;
			}
		}
	}while(!fin.eof());
	return 0;
}
0

Just to add further to what people have already said, don't put emphasis on your thread just because it's urgent to you. Other people's topics have more urgency than yours by default, because they've simply been here before you. Trying to state that your thread is more urgent than anyone else's here is just plain rude.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.