All pastes #982022 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-12 06:26 UTC
rendered paste body
//crashes with a "this application has encountered an error" window (no crash dump etc)
//Written by burlex, with a few compile fixes thrown in by me
string IRCSocket::GetToken(string& pString, unsigned int tokenId)
{
	unsigned int i; //compile fix (unsigned int)
	vector<string> tokens;
	string tok;
	for( i = 0; i < pString.length(); ++i )
	{
		if( pString[i] == ' ' )
		{
			tokens.push_back(tok);
			tok.clear();
		}
		else
		{
			tok.push_back( pString[i] ); //compile fix
		}
	}
	//last one
	if( tok.size() )
		tokens.push_back( tok );
	if( tokens.size() <= tokenId )
	{
		return "";
	}
	else
	{	
		return tokens.at(tokenId);
	}
	
	return pString;
}