istream

Hi,

Write a function that, given an istream and a vector <string>, produces a map <string ,vector <int>> holding each string and the numbers of the lines on which the string appears. Run the program on a textfile with no fewer than 1,000 lines looking for no fewer than 10 words.

Hi, I wrote the function and ran the program.
Now you read this: http://www.cplusplus.com/articles/how_to_ask/
I have read.Is forbidden to ask a question?
No, but in the OP I see no question
Read again When You Ask section
I could not do the question above. How can I make this question.
If you do not intend to help.Why have this forums.I asked for help from you.
Could you tell me.
please.
Last edited on
This forum is exactly as you say: helping. Not telling answers to homework assignments. Tell us what part of the assignment you don't get and what code you have so far. If you haven't looked into either, I advise you do so right away.
It's funny how a lot of people think they can just post the exact words of their homework assignments online and a stranger will do it for them. They don't even ask anything!
Am I wrong ?

this section.beginners section is not?
Yes, it's the Beginner section, not the IdontWantToDoMyHomeworkSoGiveMeTheSolution forum
[Edit] You could have used the time you spent complaining to ask a more proper question or to try ho to solve it
Last edited on
for sharing information.
but not to help you.
are you doing everything you can.


Thank you very much anyway

I asked the question for
regretted.

Instead of talking idly until now
Would help fifty times

Thank...


Last edited on
You have two basic options:

1: Show us what you have for the code, firix, and ask what's wrong with it. We will help you fix it without giving a full answer. This is the preferred option around here.

2: Say that you don't know where to start and ask if we could help you with starting, and we may give you a hint in English. I possibly will.

Which would you rather do? It's your choice, but you have to ask one of those two questions or a variant.

-Albatross
After writing the code to ask.
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

void readss(istream &is, vector<string> svec)
{
	string s;
	string ss;
	int count = 0;

	while(getline(is, s)) {
		istringstream iss(s);
		count = 0;
		while(iss >> ss){
		count++;
		}
		cout << "count:" << count << endl;
		cout << endl;
		if (count >= 10){
			svec.push_back(s);
			cout << endl;
		}
	}



}


int main()
{

	ifstream ifs("adad.txt");
	vector<string> svec;

	readss(ifs, svec);

	return 0;

}
I still see no question
But you used [code] tags, you are getting closer to the point where you'll get an answer
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
void  readss(istream &is, vector<string> svec)
{
	string s;
	string ss;
	int count = 0;
	int n = 0;
	map<string, vector<int>> mp;
	vector<int> ivec;

	while(getline(is, s)) {
		istringstream iss(s);
		count = 0;
		while(iss >> ss){
		count++;
		}
		//cout << "count:" << count << endl;
		cout << endl;
		if (count >= 10){
			svec.push_back(s);
			cout << endl;
		}
	}
	map<string, vector<int>>::iterator itep;
	vector<string>::const_iterator iter = svec.begin();


	ivec.push_back(0);
	while (n < 5 && iter != svec.end())
	{
		n++;
		ivec[0] = n;
		mp.insert(make_pair(*iter, ivec));
		iter++;
	}
	
	for  (itep = mp.begin(); itep != mp.end(); ++itep) {
		cout << "(" << itep->first << " , " << itep->second[0] << ")" << endl;
	}


}


int main()
{

	ifstream ifs("olbe.txt");
	vector<string> svec;

	vector<string> svec2;



	svec2 = readss(ifs, svec);

return 0;
}






I asked for the question.
answer I gave.
Is it true do you think?
I'll be very happy if you help.
my best compliments....
Last edited on
Topic archived. No new replies allowed.