How to check if a character is from keyboard in MFC
-
Hi, dear all, I need to read a component's description from a libary. but sometimes there are some garbage values at the end of descrtion string tail, I want to remove them. So after get the description, I want to check character one by one, if the character is not a character input from keyboard, I will remove them. But how can I do it? thanks!
-
Hi, dear all, I need to read a component's description from a libary. but sometimes there are some garbage values at the end of descrtion string tail, I want to remove them. So after get the description, I want to check character one by one, if the character is not a character input from keyboard, I will remove them. But how can I do it? thanks!
Andraw111 wrote:
but sometimes there are some garbage values at the end of descrtion string tail, I want to remove them.
- What type of the string is used ? - Is the garbage offset allways the same ? - Does the get-methode return the length of its answer as well ? :)
They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)
-
Hi, dear all, I need to read a component's description from a libary. but sometimes there are some garbage values at the end of descrtion string tail, I want to remove them. So after get the description, I want to check character one by one, if the character is not a character input from keyboard, I will remove them. But how can I do it? thanks!
[isalnum() ] does the job.
-
[isalnum() ] does the job.
Probably not. I think a "description" of an item would include some punctuation and spaces. Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
Probably not. I think a "description" of an item would include some punctuation and spaces. Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
Then
is_from_keyboard()
below is better suited. It includes punctuation , spaces etc.#include
using namespace std;int is_from_keyboard(int ch)
{if ( ch>31 && ch<128) return 1; else return -1;
}
int main()
{
char ch='z';if (is_from_keyboard(ch))
cout<<"The ASCII character -> "< "<
-
Then
is_from_keyboard()
below is better suited. It includes punctuation , spaces etc.#include
using namespace std;int is_from_keyboard(int ch)
{if ( ch>31 && ch<128) return 1; else return -1;
}
int main()
{
char ch='z';if (is_from_keyboard(ch))
cout<<"The ASCII character -> "< "<
void aChinaGarbageTest()
{
ASSERT(31 < _TCHAR('武') && _TCHAR('武') < 128);
}They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)