Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Check string[i] for content
Re: Check string[i] for content [message #34461 is a reply to message #34460] Wed, 23 November 2011 14:06 Go to previous messageGo to previous message
cbpporter is currently offline  cbpporter
Messages: 1428
Registered: September 2007
Ultimate Contributor
If you are doing it this way, why not use character based comparison. A string with length 1 is completely different from a character:

void term_op1(String &term, String &newterm, int &pos)
{
	char justOne = term[pos];
	
	if (justOne == '+')
	{
		newterm << " + ";
		pos++;
	} else if (justOne == '-')
	{
		newterm << " - ";
		pos++;
	} else
	{
		if (IsDigit(justOne))
		{ /* should trigger if it is a number 0-9) */
			newterm << " INT (" << justOne << ") ";
			pos++;
		} else
		{
			newterm << " Something else (" << justOne << ") ";
			pos++;	
		}
	}
}


Also, check out CParser class. It is very powerful.

PS: I did not check you code, only made it compile Smile.
 
Read Message
Read Message
Read Message
Previous Topic: What Type to give a Layout as parameter?
Next Topic: How do I get back to the .lay visual editor after a run
Goto Forum:
  


Current Time: Sun Aug 24 14:14:05 CEST 2025

Total time taken to generate the page: 0.04745 seconds