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

Comments
Still no code tags.
std::string str = "abcd123";
int i = 0;
while( str[i] && isalpha( str[i] ) ) { cout << str[i] <<" -- is alpha " <<endl; ++i; }

>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");
}
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

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 article has been dead for over six months. Start a new discussion instead.