By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,620 Members | 1,512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,620 IT Pros & Developers. It's quick & easy.

Lvalue Required...getting this error message

P: 1
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  #include<string.h>
  3.  #include<conio.h>
  4.  #include<dos.h>
  5. // #include<object.h>
  6.  
  7.  const char *hex = "0123456789ABCDEF";
  8.  
  9.  char *bin2hex(char *string);
  10.  int binstring2number(char *string);
  11.  char *number2hexstring(int nr);
  12.  
  13.  char *hex2bin(char *string);
  14.  int hexstring2number(char *string);
  15.  char *number2binstring(int nr);
  16.  
  17.  void main(void)
  18.  {
  19.  
  20.  
  21.    int x,y,z,i;
  22.    char temp_string[80];
  23.    clrscr();
  24.  
  25.    //while(!kbhit())
  26.    //     {
  27.      x=inport(0x37A);
  28.      y=x|0x20;
  29.      outportb(0x37A,y);
  30.      z=inportb(0x378);
  31.     // printf("%x",z);
  32.     temp_string[80]=z;
  33.  
  34.      //delay(200);
  35.      printf("\n");
  36.      //     }
  37.  
  38.  
  39.     printf("The value in the port is");
  40.     printf("%sb\n", hex2bin(temp_string));
  41.  
  42.     //while(!kbhit());
  43.     getch();
  44.  }
  45.  
  46.  char *bin2hex(char *string)
  47.  {
  48.     int nr = 0;
  49.     char *hexstring;
  50.  
  51.     nr = binstring2number(string);
  52.  
  53.     hexstring = number2hexstring(nr);
  54.  
  55.     return hexstring;
  56.  }
  57.  
  58.  int binstring2number(char *string)
  59.  {
  60.     int temp_nr = 0, i;
  61.     int len;
  62.  
  63.     len = strlen(string);
  64.  
  65.     for(i = 0;i != len;i++)
  66.         temp_nr |= (string[i] - '0') << (len - i - 1);
  67.  
  68.     return temp_nr;
  69.  }
  70.  
  71.  char *number2hexstring(int nr)
  72.  {
  73. //    char *temp = new char[10];
  74.     char *temp[10];
  75.     //temp=char[10];
  76.  
  77.     int i;
  78.  
  79.     for(i = 0;i < 4;i++)
  80.         temp[i] = hex[(nr >> ((3 - i) * 4)) & 15];
  81.  
  82.     temp[i] = '\0';
  83.  
  84.     return temp;
  85.  }
  86.  
  87.  char *hex2bin(char *string)
  88.  {
  89.     int nr = 0;
  90.     char *binstring;
  91.  
  92.     nr = hexstring2number(string);
  93.  
  94.     binstring = number2binstring(nr);
  95.  
  96.     return binstring;
  97.  }
  98.  
  99.  int hexstring2number(char *string)
  100.  {
  101.     int temp_nr = 0, i, j;
  102.     int len;
  103.  
  104.     if((len = strlen(string)) > 4)
  105.         len = 4;
  106.  
  107.     for(i = 0;i < len;i++)
  108.     {
  109.         for(j = 0;j != 16;j++)
  110.             if(string[i] == hex[j])
  111.                 temp_nr |= (j << ((len - i - 1) * 4));
  112.     }
  113.  
  114.     return temp_nr;
  115.  }
  116.  
  117.  char *number2binstring(int nr)
  118.  {
  119.        //char *temp = new char[20];
  120.     char *temp[10];
  121.     int i;
  122.     for(i = 0;i != 16;i++)
  123.         temp[15-i] = ((nr >> i) & 1) + 48;
  124.  
  125.     temp[i] = '\0';
  126.  
  127.     for(i = 0;i != 15;i++)
  128.         if(temp[i] == '1')
  129.             break;
  130.  
  131.     temp +=i;
  132.  
  133.     return temp;
  134.  }
  135.  

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


~added code tags
-stang02gt
Nov 11 '08 #1
Share this Question
Share on Google+
4 Replies


Stang02GT
Expert 100+
P: 1,208
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
Nov 11 '08 #2

RedSon
Expert 5K+
P: 5,000
Its C or C++ something like that.
Nov 11 '08 #3

Expert 10K+
P: 11,448
[quote=ramesh nambiar reloaded]
Expand|Select|Wrap|Line Numbers
  1.    char temp_string[80];
  2.    ...
  3.     temp_string[80]=z;
  4.  
*boing* that's an OBOE (Off By One Error)

kind regards,

Jos
Nov 11 '08 #4

100+
P: 687
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.

Expand|Select|Wrap|Line Numbers
  1.  char *temp[10];
  2.     int i;
  3.     for(i = 0;i != 16;i++)
  4.         temp[15-i] = 
'Off by 6' error.
... And you should not return pointers to local variable in this way.
Nov 11 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.