c++.dos - isXXX functions
-
noobi
(15/15)
Jul 13 2003
#include
- Heinz Saathoff (7/29) Jul 14 2003 isXXX Functions work for chars (or the integer number of a char). You
- noobi (3/32) Jul 14 2003 Big thanks for your help.
#include <stdio.h> #include <ctype.h> main() { int val, test = 2; val = isdigit(test); printf("%i \n", test); if (val != 0) puts("is a digit"); else puts("is not a digit"); return 0; } Output : 2 is not a digit Whats wrong ?
Jul 13 2003
noobi schrieb...#include <stdio.h> #include <ctype.h> main() { int val, test = 2; val = isdigit(test); printf("%i \n", test); if (val != 0) puts("is a digit"); else puts("is not a digit"); return 0; } Output : 2 is not a digit Whats wrong ?isXXX Functions work for chars (or the integer number of a char). You have assigned the integer 2 to test. Interpreted as a char it's a control char (below the space character in the ASCII table). To assign the ASCII 2 character to test write the assignment as test = '2'; /* ASCII 2 == decimal 50 */ - Heinz
Jul 14 2003
Big thanks for your help. In article <MPG.197c7537d2409aa39896c9 news.digitalmars.com>, Heinz Saathoff says...noobi schrieb...#include <stdio.h> #include <ctype.h> main() { int val, test = 2; val = isdigit(test); printf("%i \n", test); if (val != 0) puts("is a digit"); else puts("is not a digit"); return 0; } Output : 2 is not a digit Whats wrong ?isXXX Functions work for chars (or the integer number of a char). You have assigned the integer 2 to test. Interpreted as a char it's a control char (below the space character in the ASCII table). To assign the ASCII 2 character to test write the assignment as test = '2'; /* ASCII 2 == decimal 50 */ - Heinz
Jul 14 2003