0

i have to write a program that will read in a txt file that also has periods, exclamations, question marks and <CR>(returns). and do some other stuff. right now i am having trouble with comparing the words..... this is at the very bottom of my code

#include <iostream>
#include <fstream>
#include <cctype>
using namespace std;

const int MAX_LINE=201;
const int MAX_WIDTH=21;
void showcontent(fstream &);
int main()
{
	fstream dataFile;
	dataFile.open("data.txt", ios::in);

	char line[MAX_LINE][MAX_WIDTH];
	char ch;
	int i=0;
	int j=0;
	int length;
	int count=0;
	int add=0;
	int counter[MAX_LINE];

	dataFile.get(ch);
	while(!dataFile.eof())
	{
		cout << ch;
		if(isalpha(ch))
		{
			ch=tolower(ch);
			line[i][j]=ch;
			j++;
		}
		else
		{
			line[i][j]=NULL;
			i++;
			j=0;
		}
		dataFile.get(ch);
	}
	cout << endl;

	for(int m=0; m<i; m++)
	{
		for(int n=0; n<i; n++)
		{
			if(line[m] == line[n])
			{
				counter[add]=count++;
			}
		}
		cout << line[m] << endl;
		cout << counter[add] << endl;
		add++;
		count=0;
	}

	return 0;
}
2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by firstPerson
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.