I have an algorithm that I have to translate into C ++. I understand almost everything except:
If (city contains characters from 0 to 9) OR (city contains "select" or "insert")
Show "Incorrect entry"
how do we check if the character string contains numbers from 0 to 9 or words like select or insert?
and how to connect to a database?
Here is my algorithm
DEPARTMENT PROGRAM
VAR
city: Character string
START
Show 'Enter a city'
If (city contains characters from 0 to 9) OR (city contains "select" or "insert")
Show "Incorrect entry"
If not
Connection to the database
Search the city in the database
If the city is found
Show the name of the corresponding department
End if
End if
END
// Some headers
int main()
{
VAR city: Character string
Show 'Enter a city'
If (city contains characters from 0 to 9) OR (city contains "select" or "insert")
{
Show "Incorrect entry"
}
else
{
Connection to the database
Search the city in the database
If the city is found
{
Show the name of the corresponding department
}
}
}
No idea what "database" you want, but a map<string,string> would do what you appear to want.