Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Checking string for symbols
Checking string for symbols
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Sun 13 Feb 2005 07:52 PM (UTC) |
Message
| I want to check if a string to make sure that it only consists of spaces, letters, and numbers. I did something like this:
for ( let = argument; *let != '\0'; let++ )
{
if ( !isalpha(*let) )
{
send_to_char( "The clan name must only have letters in it.\n\r", ch );
return;
}
}
But a space would mean isalpha returns FALSE. Is there another function to use? |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Samson
USA (683 posts) Bio
|
Date
| Reply #1 on Sun 13 Feb 2005 08:17 PM (UTC) |
Message
| Yes. You can add a call to isspace() and it should do the trick.
Like so:
for ( let = argument; *let != '\0'; let++ )
{
if ( !isalpha(*let) && !isspace(*let) )
{
send_to_char( "The clan name must only have letters in it.\n\r", ch );
return;
}
}
| Top |
|
Posted by
| Dave
Australia (93 posts) Bio
|
Date
| Reply #2 on Mon 14 Feb 2005 06:30 AM (UTC) |
Message
| If you want numbers too you'll probably want to use isalnum() instead of isalpha().
Dave | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #3 on Tue 15 Feb 2005 01:56 AM (UTC) |
Message
| *nod* I've decided to disallow numbers anyways. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
13,499 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top