Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Mon Nov 23, 2009 5:20 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ]  Bookmark and Share
Author Message
 Post subject: help for c++ code for recognizing a valid c++ identifier?
PostPosted: Sat Jan 24, 2009 1:06 pm 
Offline

Joined: Sat Jan 24, 2009 1:04 pm
Posts: 1
What is the c++ code for recognizing a valid c++ identifier? there are some conditions to be followed:
1. it should start with a letter or an underscore
2. no two succeeding underscore.
3.the length of the identifier is from 1 to 8 characters only.
4. a single underscore inputted as an identifier is invalid.

here are the codes that i coded that are very much familiar with the problem. all i need is to combine them as one code that solves the problem above.:

/*THIS IS A SIMPLE CODE TO RECOGNIZE AN IDENTIFIER*/
#include <stdio.h>
#include <ctype.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#include <math.h>
using namespace std;

void error();
/*THIS IS A SIMPLE CODE TO RECOGNIZE AN IDENTIFIER*/
char in;
void
error()
{

in=getchar();

if(isalpha(in))
in=getchar();
else
{error();}


while(isalpha(in)||isdigit(in))
in=getchar();

}
int
main ()
{


error();

{
getch();
}
}

;;;;;;;;;;;;;;
/*THIS IS A SIMPLE CODE that RECOGNIZE a REAL NUMBER*/
#include <ctype.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#include <math.h>
using namespace std;
void error();
/*THIS IS A SIMPLE CODE that RECOGNIZE a REAL NUMBER*/
char in;
void
error()
{
in=getchar();
if(in=='+'||in=='-')
in=getchar();
while (isdigit(in))
in=getchar();
if(in=='.')
in=getchar();
else
error();
if(isdigit(in))
in=getchar();
else
error();
while(isdigit(in))
in=getchar();
cout<<"ok\n";
}
int
main ()
{


error();

{
getch();
}
}
;;;;;;;;;;;;;;;
/*THIS IS A SIMPLE CODE That implements a RECOGNIZER for AN IDENTIFIER*/
#include <ctype.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#include <math.h>
using namespace std;


/*THIS IS A SIMPLE CODE That implements a RECOGNIZER for AN IDENTIFIER*/
void error();
int main()
{
int state;
char in;

state=1;
in=getchar();
while(isalpha(in)||isdigit(in))
{
switch(state)
{
case 1:if(isalpha(in))
state=2;
else
error();
break;
case 2:state=2;
break;
}
in=getchar();
}
return(state==2);
{
getch();
}
}
void
error()
{
getch();
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review


Webmaster - Excruciating - Johnathan - Kotik - Ash - Tomi - rangana - Phate - dflynn - Medley