QUICK question
is there a way to search for a letter in a string?
NARF - Pinky and the Brain
int i = 0;
char tempLetter = string[0];
While(tempLetter != targetLetter)
{
i++;
tempLetter = string;
}
if(tempLetter == targetLetter)
cout << targetLetter << "is letter number " << i + 1;
else
cout << targetLetter << "not found" << endl;
I think that should do it.
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
char tempLetter = string[0];
While(tempLetter != targetLetter)
{
i++;
tempLetter = string;
}
if(tempLetter == targetLetter)
cout << targetLetter << "is letter number " << i + 1;
else
cout << targetLetter << "not found" << endl;
I think that should do it.
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
Without order nothing can exist - without chaos nothing can evolve.
char alpha[36] = {''A'',''B'',''C'',''D'',''E'',''F'',''G'',''H'',''I'',''J'',''K'',''L'',''M'',''N'',''O'',''P'',''Q'',''R'',''S'',''T'',''U'',''V'',''W'',''X'',''Y'',''Z'',''<'',''>'',''.''<'',''('','')'',''+'',''-'',''='',''/'',''*''};
this is what i have, yet, it comes up with error C2064
:term does not evaluate to a function
this is what i have, yet, it comes up with error C2064
:term does not evaluate to a function
NARF - Pinky and the Brain
think you''ve missed a comma
''>'', ''.''<'', ''('',
also, to search for a string you can use strstr; look it up in help for more info.
''>'', ''.''<'', ''('',
also, to search for a string you can use strstr; look it up in help for more info.
Try strchr() or strcspn(), don''t forget to include string.h
you can find the reference doc on www.cplusplus.com
you can find the reference doc on www.cplusplus.com
Paulhttp://members.lycos.co.uk/p79
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement