Help inputting text file into array of chars?

I'm having trouble trying to read a text file called "decrypted.txt" into my code while using the following code. I'm trying to input the text file into an array of chars so that once I get into the fixCapitalization function, I can iterate so that any letter after "." or "space" will capitalize the letter after it. I'm not sure if string will works in the iteration process. Any help would be great thanks!

1
2
3
4
5
for (int i = 0; i < message[length]; i++)
		{
			getline(inputFile, message[length]);
		}


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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  #ifndef MESSAGE_H_
#define MESSAGE_H_


#include <iostream>
#include "Message.h"
#include <string>
#include <fstream>
#include <string>
using namespace std;


class Message
{
private:
	char *message;   // holds the message
	int length;  // holds the the message length
	static const short ALPHABET_SIZE = 26;
	char code[ALPHABET_SIZE]; // holds the cypher alphabet
							  // iztohndbeqrkglmacsvwfuypjx
							  // ex: an 'a' in the original message should be converted to 'i', 'b' should be converted to 'z' and so forth

							  // returns the input file size in bytes

streamsize getFileSize(fstream &file) const
	{
		streamsize fsize = 0;
		file.seekg(0,ios::end);
		fsize = file.tellg();
		file.seekg(0,ios::beg); // moves file pointer back to the beginning
		return fsize;
	}
public:
	/*
	* This constructor tries to open the file whose name is passed
	* to it in filename. If file opens successfully, calls function
	* getFileSize to determine how many bytes should be allocated
	* for the message. Allocates space for message and reads the
	* content from the file into it. Closes the file at the end.
	* Member variable length should be set to the file size.
	* If file cannot be found, length should be set to zero.
	*/
	Message(string messageFile)
	{
		
		//Open the message file
		fstream inputFile;
		inputFile.open("Encrypted.txt");

		//Check if the input file has successfully open
		while (inputFile.fail())
		{
			cout << "Input file has failed to open." << endl;
		}

		//Call function getFileSize and read into an array of message
		length = getFileSize(inputFile);
		char *message = new char;
		*message = message[length];

		//Read the file
		for (int i = 0; i < message[length]; i++)
		{
			getline(inputFile, message[length]);
		}
		
		//Check to see if the file was read successfully
		for (int i = 0; i < message[length]; i++)
		{
			cout << message[i] << endl;
		} 

		
	}

	/* The destructor frees the space allocated to message
	virtual ~Message();

	// Decodes the message
	void decode();

	// Capitalizes first letter in each sentence
	void fixCapitalization();

	// Prints the content of message on the screen
	void dump() const;

	// Returns true if the message is empty
	bool isEmpty() const;
	*/
};

#endif /* MESSAGE_H_ */


int main()
{
	

	/*//Create a message object with the content of Encrypted.txt
	Message m("Encrypted.txt");


	//Check if the fie was succesfully opened
	if (m.isEmpty())
	{
		cout << "Could not read message. Make sure the file has been implemented correctly in the code or the location "
		 << "is in the same folder." << endl;
		return EXIT_FAILURE;
	}

	//Cout the original message
	cout << "Original message: " << std::endl;
	m.dump(); //Function that couts the original message
	cout << endl << endl;

	//Call the function that decodes the message
	m.decode();

	//Call the function that fixes the capitalization of the function
	m.fixCapitalization();
	
	//Call the function that prints the doceded message
	std::cout << "Decoded message: " << std::endl;
	m.dump();

	cout << endl << endl;

	return EXIT_SUCCESS;
	*/

	system("pause");
}


This is the contents of the decrypted.txt (not sure f it will help)
 
ifqkwxcadf ar cei fpoi masif cd cei xkdqirr du pxxnwafm pf pnmdkaceo cd p oirrpmi, teaqe rqkpohnir cei gpcp af ac-oplafm ac sikw gauuaqvnc pfg caoi qdfrvoafm, au fdc xkpqcaqpnnw aoxdrrahni, cd gigvqi cei dkamafpn masif dfnw cei ifqdgig gpcp. afxvcr cd cei pnmdkaceo cwxaqpnnw afsdnsi pggacadfpn riqkic gpcp qpnnig liwr, teaqe xkisifcr cei oirrpmi ukdo hiafm giqdgig-isif au cei pnmdkaceo ar xvhnaqnw lfdtf.
Topic archived. No new replies allowed.