I have char data variable which gives (o/p comes from pc's hyper terminal and i am comparing its inside microcontroller) me known string with known length like "ASDF".
Now I want to store this variable's o/p to a char array char dataarray[5];
And I had other char array char newdata[8]="ASDF\r\n"; so that I can compare both string using if(strcmp(dataarray[i],name2) == 0)
something like
char data;
char dataarray[5];    
char newdata[8]="ASDF\r\n";
if(strcmp(dataarray[i],newdata[j]) == 0)
So what should I need to change?
void main()
{
   char *data;    
   char *old;    
   char *match;    
   char *nomatch;       
   nomatch = "not";    
   match = "yes";    
   old = "HJB";     
   int m;
   USARTInit(25);    //UBRR = 51
   //Loop forever
   while(1)
   {            
        data=USARTReadChar();
        if(strcmp(data,old) == 0)
        {
          for(m=0;m<3;m++)
          {
            USARTWriteChar(match[m]);
          }
        }
        else{USARTWriteChar(nomatch);
    }              
}
				
                        
You can make use of array indexing to achieve this. Please check the below pseudo-code
Then, you can use
dataarrayfor any string related operation, saystrcmp(), for example.