#include <string>

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
Peter3109
New poster
Posts: 6
Joined: Sat Jan 14, 2006 9:38 am

#include <string>

Post by Peter3109 » Sat Jan 14, 2006 9:40 am

I seem to get compile error whenever I include <string>. I am sure that I have used it before, has something changed?

Thx.

Peter

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun » Sat Jan 14, 2006 11:23 am

Post your code. At least the top portion.

Peter3109
New poster
Posts: 6
Joined: Sat Jan 14, 2006 9:38 am

Post by Peter3109 » Sun Jan 15, 2006 8:12 am

Code: Select all

#include <iostream>
#include <set>
#include <string>
using namespace std;

set<string> words;
string word;
string inword;

void add() {
	int j = 0;

	word.clear();
	for(int i = 0; i < inword.size(); i++) {
		if(inword[i] >= 'A' && inword[i] <= 'Z')
			inword[i] += 'a' - 'A';
	}
	
	while(inword[j] < 'a' || inword[j] > 'z')
		j++;
	while(inword[j] >= 'a' && inword[j] <= 'z'){
		word.push_back(inword[j]);
		j++;
	}
	words.insert(word);
	return;
}


int main() {
	while(cin>>inword)
		add();
	for(set<string>::iterator itr = words.begin(); itr != words.end(); itr++)
		cout<<*itr<<"\n";
	return 0;
}
Any help appreciated!!

Peter

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun » Sun Jan 15, 2006 8:46 am

Code: Select all

word.clear();
string.clear() isn't allowed in OJ.

Peter3109
New poster
Posts: 6
Joined: Sat Jan 14, 2006 9:38 am

Post by Peter3109 » Sun Jan 15, 2006 9:20 am

Thanks!

Post Reply

Return to “C++”