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

William Hemsworth commented: Still no code tags. -1

Recommended Answers

All 4 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.