Is there any way to detect how many times cretin characters can appear in a serial number ? EX if I have a code of 12 characters including letters and numbers in this code. I want to make sure that user will use only number four for once. Using if statement what's the possibility to get that function?


In this following code I made sure that the user will promote 12 characters only. Should I copy the serial code into an array then do searching for number four and once the program detects that the user used number four more than once it sends an error, or is there an easier way to do so?

Code:
#include <iostream>
#include<string>
using namespace std;

int main()
{
   string serial_number; 
	int length=0;

		
	cout<< "please enter a serial number of 12 characters:";
	cin >> serial_number;
	length=serial_number.length();
	
	if (length!=12 )
		cout << "The code you have entered cannot be processed because the code must be contained of 12 characters exactly";
	else 
		cout << " that's correct code";

	return 0;
}