CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

What is wrong with this code?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
No_Fear
Guest







What is wrong with this code?
PostPosted: Sun Jan 26, 2003 4:49 pm     Reply with quote

Hi There,

Sometime ago i asked here how to convert hex values to int values.Thanks to PCM_Programmer replied my question and sent me a piece of code.I copied this code and pasted then i compiled it with Ide Vers 3.20 and PCM v3.112, but it gives "Expecting LVALUE such as a variable name or * expression" on line includes "c = *ptr++;".What is wrong with this code? I can compile this piece of code with borland c++ builder v4.0 without any problem!! Can you advice me please?
Thanks.

char Hex2Int(char ptr[2])
{
char i, c, value;
value = 0;
for(i = 0; i < 2; i++) // Convert a maximum of 2 digits
{
c = *ptr++; // Get the char *** This Probl. Line ***
if(c >= 'a') // If char is lower case,
c &= 0x5f; // convert to upper case.
if(c < '0') // Check if the char is an ascii hex char
break;
if(c > 'F')
break;
if(c < 'A')
{
if(c > '9')
break;
} c -= 0x30; // Convert the char to binary
if(c > 9)
c -= 7;
value <<= 4; // Shift existing value left 1 nybble
value |= c; // Then combine it with new nybble
}
return(value);
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 11013
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: What is wrong with this code?
PostPosted: Sun Jan 26, 2003 5:42 pm     Reply with quote

I copied this code and pasted then i compiled it with Ide Vers 3.20 and PCM v3.112, but it gives "Expecting LVALUE such as a variable name or * expression" on line includes "c = *ptr++;".What is wrong with this code? I can compile this piece of code with borland c++ builder v4.0 without any problem!! Can you advice me please?
:=
:=char Hex2Int(char ptr[2])
---------------------------------------------------------
Change the line above to become this:

char Hex2Int(char *ptr)

If you're using Function Prototypes, make sure you
also change it there.
___________________________
This message was ported from CCS's old forum
Original Post ID: 11016
No_Fear
Guest







Re: What is wrong with this code?
PostPosted: Mon Jan 27, 2003 11:29 am     Reply with quote

Thank you! It compiles now.

:=I copied this code and pasted then i compiled it with Ide Vers 3.20 and PCM v3.112, but it gives "Expecting LVALUE such as a variable name or * expression" on line includes "c = *ptr++;".What is wrong with this code? I can compile this piece of code with borland c++ builder v4.0 without any problem!! Can you advice me please?
:=:=
:=:=char Hex2Int(char ptr[2])
:=---------------------------------------------------------
:=Change the line above to become this:
:=
:=char Hex2Int(char *ptr)
:=
:=If you're using Function Prototypes, make sure you
:=also change it there.
___________________________
This message was ported from CCS's old forum
Original Post ID: 11041
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group