Right now i am having difficulty skipping the blank lines in the txt file i read in. I read in all the material i need, but the blank lines come in too and messes up my array.

this is my txt file
####
#M##
#..#
##.#
#..#
####

0

S
E
S
W

0

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

int main()
{
	ifstream dataFile;
	dataFile.open("mice.txt");

	char maze[10][10];
	//char direction[10][1];
	int i=0;
	int j=0;
	char output;

	dataFile.get(output);
	while(output != '0')
	{
		if(output != '0' && output != '\n')
		{
			maze[i][j] = output;
			cout << maze[i][j] << endl;
			j++;
		}
		else
		{
			maze[i][j] = NULL;
			i++;
			j=0;
		}
		//if(output == 'E' || output == 'S' || output == 'W' || output == 'N')
		//{
		//	direction[m][n] = output;
		//	m++;
		//}
		dataFile.get(output);
	}

	for(int m=0; m<(i-1); m++)
	{
		for(int n=0; n<4; n++)
		{
			cout << maze[m][n];
		}
		cout << endl << endl;
	}
	



	dataFile.close();

	return 0;
}

could i use isspace?

Are you sure your file isn't saved with carriage-return linefeeds, '\r\n' instead of just '\n'?

Having a variable called 'output' for something which is plainly input isn't at all confusing :icon_rolleyes:

To answer your question, read each line using getline()
Then parse the line for the information you need.

With your approach as it stands, if your code is off by even 1 character, the rest of the program is broken.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.