-1

HI i want to know how to use isalpha in my prog please help me out
printf("Enter the ip address using '.' as a seperator after each octet only integers\n"); /* Printing the statement*/

scanf("%d.%d.%d.%d.",&ip[0],&ip[1],&ip[2],&ip[3]); /* Reading the values of ip address and storing integer values*/

printf("Enter the subnetmask address using '.' as a seperator after each octet only integers\n"); /*Printing the statement*/

scanf("%d.%d.%d.%d.",&mask[0],&mask[1],&mask[2],&mask[3]);

how to use isalpha to chech for a character

Votes + Comments
Still no code tags.
3
Contributors
4
Replies
6
Views
8 Years
Discussion Span
Last Post by firstPerson
0
std::string str = "abcd123";
int i = 0;
while( str[i] && isalpha( str[i] ) ) { cout << str[i] <<" -- is alpha " <<endl; ++i; }
0

>how to use isalpha to chech for a character
Check the reference.
Next time, if you intent to ask a C-related question, check out the C Forums of this website.

By the way, a quick example of isalpha is:

#include<stdio.h>
int main()
{
  char c;
  printf("Enter a char");
  scanf("%c",&c);
  if(isalpha(c)) printf("The char you entered was an alphabet");
  else printf("The char you entered was not an alphabet");
}
0
std::string str = "abcd123";
int i = 0;
while( str[i] && isalpha( str[i] ) ) { cout << str[i] <<" -- is alpha " <<endl; ++i; }

my question is in my above posted program if i give ip address as 123.23a.34.34
it has to display invalid ip address because a alphabet is used

0

my question is in my above posted program if i give ip address as 123.23a.34.34
it has to display invalid ip address because a alphabet is used

You might want to check out ispunct

For the '.' you have in the ip.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.