472,805 Members | 1,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

Lvalue Required...getting this error message

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
4 2348
Stang02GT
1,208 Expert 1GB
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
5,000 Expert 4TB
Its C or C++ something like that.
Nov 11 '08 #3
JosAH
11,448 Expert 8TB
[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
newb16
687 512MB
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

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

Similar topics

5
by: Sai Krishna M | last post by:
Lvalue Required......Why? Hello all, the following code is not compiling in Turbo C and the error is "Lvalue Required" . main() {
13
by: wessoo | last post by:
Hi All. What is The Lvalue Required error message. (What does it mean?Is it an abbreviationof something.) I wrote this test program and I am keeping geting this message. void main() {...
24
by: Romeo Colacitti | last post by:
Hi, Does anyone here have a strong understanding for the meanings of the terms "lvalue" and "rvalue" as it pertains to C, objects, and different contexts? If so please share. I've been...
14
by: Akhil | last post by:
plz c d following code #include<stdio.h> void main() { int x=4,y=1; y=x++++; //gives error message lvalue required y=x++ + ++y;//no errors
3
by: Kavya | last post by:
Can someone give and explain in simple terms a definition of lvalue? Also what are these modifiable and non-modifiable lvalues? I always thought that, if we can assign to anything then that...
16
by: raghu | last post by:
#include<stdio.h> int main(void) { int a=1; int b=2; int c=0; c=(a+b)++; printf("%d",c); return 0; }
4
by: Shraddha | last post by:
Sometimes we get an error of lvalue requred?What exactly is the lvalue? And when this error occures?
1
by: yyhkitty | last post by:
Hi, I keep getting two invalid lvalue in assignment errors. here's what my code looks like: pthread_t msg_receive(char *sbuffer, int *maxlen) { // get the values for sbuffer and maxlen ...
11
by: markryde | last post by:
Hello, Followed here is a simplified code example of something which I try to implement; in essence , I want to assign a value to a return value of a method is C. I know, of course, that in this...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.