stringstream error

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
void addition()
{
	string file1,file2;
	string line,word;
	istringstream get;

	 int **matrix;
	 int m ,n ; //m= rows , n=columns

	cout<<"You are using addition function now . \n";

	cout<<"Please enter the first file name that contains matrix :";
	getline(cin,file1);
	cout<<endl;

	cout<<"Please enter the second file name that contains matrix :";
	getline(cin,file2);
	cout<<endl;

	ifstream infile(file1,ios::in) ;
	
	if(!infile)
	 {
		 cerr<<"File 1 open error";
		 system("cls");
		 main();


	 }
	else 
		
	 {		
		 getline(infile,line);//getline for </matrix>
		 
		 getline(infile,line);//getline for rows
		
		 get.clear();//clear get stream;
						
		 get(line);

		 get>>word;

		 get>>word;

		 get>>m;

		 getline(infile,line);//getline for column

		 get(line);

		 get.clear();

		 get>>word; //read column
		 get>>word; //read =
		 get>>n;	//store column number

	 }


}


Didn't want to open a new thread to save forum resources , but since no one answer it for 2 days I'll just ask again .

So this is the part where I should do addition of matrix , but in the part get(line) I have this error


IntelliSense: call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type

What's wrong ?

I haven't do the matrix calculations yet , will work on it later .
Last edited on
get(line); this is wrong. Use getline to read a line like you have done earlier in your program.
But I have a file like this

<matrix>
rows = 2
cols = 2

1 2
2 4
</matrix>

I want to ignore the rows= and cols= and extract only the 2 .
ios::in is implied for an ifstream, so you open the input file stream like this:
 
	ifstream infile(file1);


Don't call main()
1
2
3
4
5
6
	if(!infile)
	{
		 cerr<<"File 1 open error";
		 system("cls");
		 main();
	 }


What is the format of your input?
just a quick question

if I use string stream

and

stream(line)

does it mean that I access the stream and store the input into line?
It's not clear what you're asking. However, this thread might help.
http://www.cplusplus.com/forum/general/72375/#msg386381
Topic archived. No new replies allowed.