473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How can I know if a Char is a digit?


Is there any function to know if a char is a digit
Thanks in advantage....
Nov 15 '05 #1
5 4899
Char.IsDigit(c);

"Hector Martinez" <an*******@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...

Is there any function to know if a char is a digit?

Thanks in advantage....

Nov 15 '05 #2
char.IsDigit

"Hector Martinez" <an*******@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...

Is there any function to know if a char is a digit?

Thanks in advantage....

Nov 15 '05 #3
If you need to check a set of characters, a regular expression will do the
trick more easily than looping through the characters in the string, testing
each one.

--
Dave Veeneman
Chicago
Nov 15 '05 #4
Dave Veeneman <da****@nospam.com> wrote:
If you need to check a set of characters, a regular expression will do the
trick more easily than looping through the characters in the string, testing
each one.


Indeed it will - and in simple cases it may be more easily readable
too. In other cases, however, it'll be less readable as the regular
expression becomes harder to understand to the human eye. Also, using
straight code will be significantly faster, if performance is an issue.
(Performance should only be taken into consideration when it's actually
proved to be problematic.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #5
Dan,

The regular expression might do it more easily, but if you don't know
regular expression syntax, the looping is easier to code. I personally have
always had a great deal of trouble relaly understanding regular expression
syntax in Unix or in .NET. But that's just me.

Pete

"Dave Veeneman" <da****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
If you need to check a set of characters, a regular expression will do the
trick more easily than looping through the characters in the string, testing each one.

--
Dave Veeneman
Chicago

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: muser | last post by:
is string converted to its integer equivalent by minusing it by 48? the function is suppose to check the fifth digit of struct member using the formula contained within the function. The function...
9
by: | last post by:
void show( char *s, ...) is a function seemd like prinf code -------------- #include <stdio.h> #include <stdarg.h> void show( char *s, ...) { va_list stage;
20
by: Drebin | last post by:
It's a long story really, but the bottom line is we need to encrypt or obfuscate a clear-text 9-digit SSN/taxpayer ID into something less than 21 characters. It doesn't need to be super-secure,...
14
by: Drew | last post by:
Hi All: I know I am missing something easy but I can't find the problem! I have a program which reads an integer as input. The output of the program should be the sum of all the digits in the...
5
by: rajus | last post by:
How to convert a char array to an int array?So if char s={"1234"}; then the int array say 'num' should have values num= 1 num=2 and so on.
80
by: Gaijinco | last post by:
Is there an elegant way to do something like // given a char {0,1,2,3,4,5,6,7,8,9} returns it as a short short char2digit(char c) { short d = c-48; return d; } ?
5
by: Omats.Z | last post by:
what is meaning os "char **option meet"? I get a function like this: __________________________________ int getchoice(char *greet, char *choices) { int chosen = 0; int selected; char **option;...
1
by: ad | last post by:
From the past posted, I know char c = (char)rnd.Next('a', 'z' + 1); can generate a alpha randomly. But now I want to generate a alpha or a digit randomly. ('0'..'9' or 'a'..'z') How can I...
14
by: thehobbit | last post by:
Hi, Could anyone give ideas on how to add 4 20 digit numbers in ANSI C and pass the result back to a calling program in COBOL? We were able to add up to 15 digit numbers without any problems,...
7
by: abhinuke | last post by:
Been brushing up my C,C++ for my new venture in Graduate Studies for this fall.I am doing basic programs in which I am trying this one right now. A 5-digit positive integer is entered through the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.