Car platenumber

I have to make a programm with C++ which recognizes the car palatenumber.
Normal platenumber for example 123ABC
Not a local platenumber 1R or CLOUD7
I know that I need to use strings to do it, but I have no idea how to put it that it will recognize that in the platenumber there is like 2 numbers and 5 letters.
I would be so happy if someone can help me!
Put this input string in a loop until it reaches end of string, then take each character and check if they are alphabet or number using their ascii...
u should use this algo and try to code it yourself...
Maybe you should read the string with the getline function because this one stores the entire string into an array of characters, and then you do what SUH said.
Thank you, but how do I take each character and how do I check it?
I am so sorry about my lack of knowledge.
you can access strings as if they were arrays... e.g:

1
2
3
4
for (int size = 0; size < sentence.size(); ++size) {
	if (sentence[size] < 0)
		//...
}
Last edited on
You can do it exactely as you can acces a vector-component, by it's index:
This is the vector version:
1
2
3
4
int vec[1000];
vec[1]=3;
vec[4]=23;
...............

This is the char-version:
1
2
3
4
char vec[10000];
vec[1]='a';
vec[2]='F';
................

If you put this accesing-method in a for-loop you can manipulate you entire array by one crossing (look at chipp's post).
Topic archived. No new replies allowed.