Need Help Urgent Due This Morning C++ Project

This is what i have so far i know its wrong im totally new to programming this is my first semester of C++ i have tried looking in book on the internet and still can not figure this out what i have to do is this use file I/O to read in a file that has three lines of text, and then for each line of text i have to take the first integer in each line and turn that into its Ascii Value equivalent Character value , then for the second integer in the line that becomes the field width , the next character in the line of text becomes the Left or Right justification and then the string at the end just has to get printed out at the end so for example if the line of text from the file reads "85.2 12k r C++ is fun" then i should get "UUC++ is fun"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <fstream> //needed for file manipulation
#include <iomanip>
#include <string> //needed for strings

using namespace std;

int main()
{

	//declare variables
	ifstream inFile;		 //input file Variable
	ofstream outFile;		 //output file variable
	string fileName;		 //string for input file
	char leftJustify = 'l';
	char leftJustify2 = 'L';
	char rightJustify = 'r';
	char rightJustify2 = 'R';
	int asciiInteger;
	int fieldWidth;
	char asciiValue;
	string lastString;

	//Ask user for file name have them enter it
	cout << "Please enter file name or path: " << endl;
	getline(cin , fileName);
	inFile.open(fileName);

	char outputFilename[] = "out.list";

	//if file is not found have program exit
	if(!inFile.is_open())
	{
		cout << "File Not found" << endl;
		exit(1);
	}

	//else do processing
	cout << fixed << showpoint;
	cout << setprecision(2);
	cout << "Processing data" << endl;
	cout << endl;
	cout << endl;

	
	while(inFile >> asciiInteger >> fieldWidth >> leftJustify2)
	{
		asciiValue  = char(asciiInteger);
		cout << asciiValue << fieldWidth << leftJustify2 << endl;

	}

	return 0;

}

Last edited on
Topic archived. No new replies allowed.