Passing vector of strings and comparing to ASCII values

Im using the SFML library and the TGUI library, first one to create a window and the second to have text boxes to get some user input.

I take the text, convert to ansiString and store it in a vector of strings.

I then pass the vector to a function, where I want to make sure the inputted text is valid by checking that each element of every string in the vector falls within the correct ASCII range (in this case, each string should be 0-9 only).

My function is:

1
2
3
4
5
6
7
8
9
10
void Information::isValid(std::vector <std::string> &num)
{
     for(int i = 0; i< num[i].length(); i++)
        {
             if(!(num[i] > 47 && num[i] < 58))
              {
                 //do something
              }
        }
}


Now this doesn't work because num[0] is the first string in the vector and you can't compare that, so how do I code it such that it starts by comparing the first element of the first string?
Woop woop!

Figured it out meself!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void Information::isValid(std::vector <std::string> &num)
{
	for (int i = 0; i < num.size(); i++)
	{
		for (int j = 0; j < num[i].length(); j++)
		{
			if (!(num[i][j] > 47 && num[i][j] < 58))
			{
				//do something
			}
			else
			{
				//do something
			}
		}
	}
}
Topic archived. No new replies allowed.