Lvalue Required...getting this error message

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramesh nambiar reloaded
    New Member
    • Nov 2008
    • 1

    Lvalue Required...getting this error message

    Code:
    #include<stdio.h>
     #include<string.h>
     #include<conio.h>
     #include<dos.h>
    // #include<object.h>
    
     const char *hex = "0123456789ABCDEF";
    
     char *bin2hex(char *string);
     int binstring2number(char *string);
     char *number2hexstring(int nr);
    
     char *hex2bin(char *string);
     int hexstring2number(char *string);
     char *number2binstring(int nr);
    
     void main(void)
     {
    
    
       int x,y,z,i;
       char temp_string[80];
       clrscr();
    
       //while(!kbhit())
       //	 {
    	 x=inport(0x37A);
    	 y=x|0x20;
    	 outportb(0x37A,y);
    	 z=inportb(0x378);
    	// printf("%x",z);
    	temp_string[80]=z;
    
    	 //delay(200);
    	 printf("\n");
         //	 }
    
    
    	printf("The value in the port is");
    	printf("%sb\n", hex2bin(temp_string));
    
    	//while(!kbhit());
    	getch();
     }
    
     char *bin2hex(char *string)
     {
    	int nr = 0;
    	char *hexstring;
    
    	nr = binstring2number(string);
    
    	hexstring = number2hexstring(nr);
    
    	return hexstring;
     }
    
     int binstring2number(char *string)
     {
    	int temp_nr = 0, i;
    	int len;
    
    	len = strlen(string);
    
    	for(i = 0;i != len;i++)
    		temp_nr |= (string[i] - '0') << (len - i - 1);
    
    	return temp_nr;
     }
    
     char *number2hexstring(int nr)
     {
    //	char *temp = new char[10];
    	char *temp[10];
    	//temp=char[10];
    
    	int i;
    
    	for(i = 0;i < 4;i++)
    		temp[i] = hex[(nr >> ((3 - i) * 4)) & 15];
    
    	temp[i] = '\0';
    
    	return temp;
     }
    
     char *hex2bin(char *string)
     {
    	int nr = 0;
    	char *binstring;
    
    	nr = hexstring2number(string);
    
    	binstring = number2binstring(nr);
    
    	return binstring;
     }
    
     int hexstring2number(char *string)
     {
    	int temp_nr = 0, i, j;
    	int len;
    
    	if((len = strlen(string)) > 4)
    		len = 4;
    
    	for(i = 0;i < len;i++)
    	{
    		for(j = 0;j != 16;j++)
    			if(string[i] == hex[j])
    				temp_nr |= (j << ((len - i - 1) * 4));
    	}
    
    	return temp_nr;
     }
    
     char *number2binstring(int nr)
     {
           //char *temp = new char[20];
    	char *temp[10];
    	int i;
    	for(i = 0;i != 16;i++)
    		temp[15-i] = ((nr >> i) & 1) + 48;
    
    	temp[i] = '\0';
    
    	for(i = 0;i != 15;i++)
    		if(temp[i] == '1')
    			break;
    	
    	temp +=i;
    
    	return temp;
     }

    while debugging i got error like Lvalue Required....
    plse suggest a solution..


    ~added code tags
    -stang02gt
  • Stang02GT
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    What language is this?

    Please make sure you are using code tags when you are posting your code. And I think you are going to need to provide more information if we are going to try and help you.

    You need to read our Posting Guidellines

    Comment

    • RedSon
      Recognized Expert Expert
      • Jan 2007
      • 4980

      #3
      Its C or C++ something like that.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        [QUOTE=ramesh nambiar reloaded]
        Code:
           char temp_string[80];
           ...
        	temp_string[80]=z;
        *boing* that's an OBOE (Off By One Error)

        kind regards,

        Jos

        Comment

        • newb16
          Contributor
          • Jul 2008
          • 687

          #5
          Originally posted by ramesh nambiar reloaded
          while debugging i got error like Lvalue Required....
          When *compiling*. When you press debug, it compiles and links first and then debug.

          plse suggest a solution..
          Identify location ( by line number mentioned in error message). Identify left part of the assignment. Fin wy it can't be there.

          Code:
           char *temp[10];
              int i;
              for(i = 0;i != 16;i++)
                  temp[15-i] =
          'Off by 6' error.
          ... And you should not return pointers to local variable in this way.

          Comment

          Working...