comparing a numerical string

my project needs to compare a numerical string read from a rfid reader.
i can able to see the value of rfid value in serial monitor using the code

#include <SoftwareSerial.h>

SoftwareSerial mySerial(8,9); // RX, TX
int a;
void setup()  
{
  
  Serial.begin(9600);
  while (!Serial) 
  {
    ; 
  }
  Serial.println("rfid identity value!");
  mySerial.begin(9600);
 
}

void loop() 
{
  if(mySerial.available())
 
  {
  Serial.write(mySerial.read());
  
 }

 }

now i want to compare the value .for example i am having two tags of dif values(say 08160978 & 08201290)..i want to assign dif opertioon with respect to the tag.....so i want to compare the serial value from reader....so wat shud i do nw?

You should read the data into an array, and either use memcmp or strcmp to compare.

can u give me a sample code r can u edit my existing code.plz

I could, but that would be no fun for you.

no sir i am new to this environment and my dead line for my proj submision is very near......

check the tutorial - http://arduino.cc/en/Tutorial/StringComparisonOperators -
it has more than you need.

thank u sir .but i couldnt see the value of the variable in which i have stored the serial data...

#include <SoftwareSerial.h>

SoftwareSerial mySerial(8,9); // RX, TX
int a[8] ; 
void setup()  
{
  
  Serial.begin(9600);
  while (!Serial) 
  {
    ; 
  }
  Serial.println("rfid identity value!");
  mySerial.begin(9600);
 
}

void loop() 
{
  if(mySerial.available())
   {    
  a = mySerial.read();
   }
   Serial.println(a);

}

ERROR:its showing as "incompatible types in assignment of int to int[8]"
C:\Program Files\Arduino\hardware\arduino\cores\arduino/Print.h:75: note: size_t Print::println(long unsigned int, int)

my serial value from rfid reader is a 8 digit valu.so can i declare it as a long int?????

I think what you find on this Forum is that people are willing to point you in the right direction, but would prefer that you learn from the experience, rather than just providing an answer. It is a give-a-man-fish versus teach-a man-how-to-fish thing. Further, no one really cares that you have a deadline coming up...we all have deadlines. That said, in your statement:

  a = mySerial.read();

What do you think the variable a is? a is viewed by the compiler as the memory address of where the array named a is stored in memory. Let's assume that the compiler has placed your array at memory location 1000. If the byte coming in from read() is, let's say the character '0' (zero), that has an ASCII value of 48. So, your statement is trying to change the memory address of a from 1000 to 48. The memory address of a variable, also called its lvalue, is constant and the compiler rightly will not let you change it.

As a hint, the statement:

  a[index] = mySerial.read();

says to take the byte just read and assign it into element a[index] of the array. Now go read the references what were given to you and I think you'll be able to better figure things out.

sir really i couldnt figure out a way????

#include <SoftwareSerial.h>

SoftwareSerial mySerial(8,9); // RX, TX
int a[8] ; 
void setup()  
{
  
  Serial.begin(9600);
  while (!Serial) 
  {
    ; 
  }
  Serial.println("rfid identity value!");
  mySerial.begin(9600);
 
}

void loop() 
{
  if(mySerial.available())
   { 
for9(i= 0; i <8; i++)
{   
  a[i] = mySerial.read();
   }}
   Serial.println(a);

}

What?

for9(i= 0; i <8; i++)

What is for9? You should be able to catch this kind of error before even posting it here.

You should be able to catch this kind of error before even posting it here.

And if you can't, the compiler will.

sir still i couldn't get a proper output

#include <SoftwareSerial.h>

SoftwareSerial mySerial(8,9); // RX, TX
int A[8];
int i;
void setup()  
{
  
  Serial.begin(9600);
  while (!Serial) 
  {
    ; 
  }
  Serial.println("rfid identity value!");
  mySerial.begin(9600);
 
}

void loop() 
{
  if(mySerial.available())
  {
    for (i = 0; i < 8; i++ )
    {
  A[i] = mySerial.read();
  delay(500);
    }
    Serial.println(A[4]);
    delay(1000);
  }
 }

now the value of A[4] is dipalyed as-1 48 -1 (read many times same tag).without that 2 delays i got some continuous -1 -1 -1 -1 irespective of the tag.

 if(mySerial.available())
  {
    for (i = 0; i < 8; i++ )
    {
  A[i] = mySerial.read();
  delay(500);

See if there's at least one character to read, then go ahead and read all eight of them.
That's why you "need" the delay.
Why not check to see if there's something to read, before reading it?
.

how can i check that...already i have included the line if(mySerial.available())...thn wat else i shud include.

already i have included the line

And, what does that method return? Go look that up before responding.

sorry sir i cant get u.

Clue