no match for 'operator>>'

I'm trying to read in a number of rows and columns from the first line of a text file. They're the first two items in the file, and separated by spaces.

Here are my includes:
1
2
3
#include <iostream>
#include <fstream>
using namespace std;


And here's the function I'm having trouble with:
1
2
3
4
5
6
7
8
9
char * read_maze(char *filename, int *rows, int *cols )
{
	char * mymaze = new char [*rows * *cols];
	ifstream mazein;
	mazein.open (filename);
	mazein >> rows >> cols;
	mazein.close()
	return mymaze;
}


When I make my program, I get
error: no match foroperator>>’ in ‘mazein >> rows’

My code is not finished, so if there are loose ends or useless declarations, I haven't yet gotten to coding that. Please try to ignore any other issues/problems/preferences and just help me with the operator problem.
Last edited on
rows is a pointer-to-an-int. You're trying to store the input data in a pointer-to-an-int. Did you meant to store it in an int?
I hadn't thought that could cause an operator error. I added a * before rows and cols and it works. Thank you! (just learned pointers and references as well)
operators are just shorthand for function calls. If there is no operator >> written that knows what to do with input parameters ifstream and pointer-to-int (as in this case), you get an error much as if you were trying to call a function that doesn't exist.
Topic archived. No new replies allowed.