![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| to check variable if its non numeric | sachin.gangadha | Shell Programming and Scripting | 3 | 12-06-2007 05:33 PM |
| Check for numeric inputs | Raynon | Shell Programming and Scripting | 6 | 08-22-2007 03:17 AM |
| How to check for a valid numeric input | Vijayakumarpc | Shell Programming and Scripting | 1 | 08-04-2007 08:34 AM |
| How to check a column contain numeric or char data type ?? | jambesh | Shell Programming and Scripting | 12 | 10-06-2006 10:37 AM |
| Convert string to numeric | kflee2000 | Shell Programming and Scripting | 3 | 11-19-2003 11:21 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||||
|
You are trying with following standard C library function:
This function test only for decimal-digit character http://www.freebsd.org/cgi/man.cgi?q...SD+6.2-RELEASE This function test for hexadecimal-digit character http://www.freebsd.org/cgi/man.cgi?q...SE&format=html Best regards, Iliyan Varshilov Last edited by ilko_partizan; 06-18-2007 at 08:24 AM.. |
|
|||||
|
You are trying to solve your validation problem with regular expression library function .
http://www.opengroup.org/onlinepubs/...s/regcomp.html Best regards, Iliyan Varshilov Last edited by ilko_partizan; 06-18-2007 at 08:46 AM.. |
|
||||
|
Quote:
Code:
#include <stdlib.h>
short strchk (char *s) {
unsigned short r = 0;
while (*++s) {
if (isdigit(s)) {
r = 1;
} else {
r = 0;
break;
}
}
return r;
}
|
|
||||
|
That routine does not check the first character of the string...
Try Code:
int is_numeric(const char *p) {
if (*p) {
char c;
while ((c=*p++)) {
if (!isdigit(c)) return 0;
}
return 1;
}
return 0;
}
|
| Sponsored Links | ||
|
|