a program wherein you input a 8 character string..and then validate if its a valid identifier..a valid identifier is a string that starts with an alphabet and underscore(_)..invalid identifier starts with a number and a double underscore(__)

Here you go

for space how to declare it as an invalid this is my sample program and it will make the space valid.

#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <string.h>
int main ()
{
char input[50];
int i,l;
h:
printf("Enter an identifier:");
scanf("%s",input);
l=strlen(input);
    if (isalpha(input[0])){
    for(i=0;i<l;i++){
      if((input[i]=='+')||(input[i]=='-')||(input[i]==' ')||(input[i]=='=')||(input[i]=='"')
      ||(input[i]=='#')||(input[i]=='@')||(input[i]=='!')||(input[i]=='.')||(input[i]==')')||(input[i]=='(')||(input[i]=='*')){
      printf("Invalid!");
      break;
      }
      else if(i==l-1){
          printf("Valid!");
          }
        }
      }
    else{
    printf ("Invalid!");
    }
printf("\n");
goto h;
}

7Up...valid identifeie or not...??

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.