From the command line, I want to write a for loop that will detect if there is a string or char in the array from the command line arguments.
For example, a person enters 4.3, 5, 99, 0.1, w, 4, 2.43. Right when the loop detects the char w, it will print "Error." Same thing goes for if the input was 4.3, 5, 99, 0.1, wasabi, 4, 2.43; when the loop detects the string wasabi it will display an error message. The thing that I cannot figure out is how to write the loop so that it detects ANY char or string, no matter where it is on the array. This is what I have so far:
//check for a string or char in array
void checkForWord(int argc, char* argv[])
{
for (int i = 1; i < argc - 1; i++)
{
if ()
{
//do something..
}
}
}
Any help would be much appreciated!!
Aucun commentaire:
Enregistrer un commentaire