We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,608 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to program using const uint8_t* const x?

Hi i am going to make a Binary Utility but I don't knnow how to program using

extern uint16_t Bcdbin(const uint8_t* const pBcdBin)

I have already read about extern and about unsigned int but I don't understand how to make a function for that code. please help. ty

2
Contributors
2
Replies
1 Hour
Discussion Span
10 Months Ago
Last Updated
3
Views
keryll
Newbie Poster
3 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

What do you know about binary coded decimal representation? That appears to be what the function's intended purpose is, which is a bigger issue than the type of pBcdBin.

But the type of pBcdBin is a pointer to zero or more bytes (that's what uin8_t represents here), where neother the pointer itself nor the bytes may be changed, they're both immutable. Technically you could simplify the function signature like so:

short BcdBin(unsigned char *pBcdBin);

This takes advantage of the fact that short int is at least 16 bits and unsigned char is at least 8 bits. The const qualifiers probably aren't necessary, but they make your life easier by enforcing immutability inside the function (ie. stop you from changing them accidentally).

deceptikon
Challenge Accepted
Administrator
3,500 posts since Jan 2012
Reputation Points: 822
Solved Threads: 481
Skill Endorsements: 58

Hi!. the code above is to be used to Convert a two-byte, 3-digit, BCD number into a binary value.
thank you for explaining what the function is, since I was very confused before on how or what their purpose is.
I'm afraid i have to use the above code and can't change it. :(

so a two byte BCD number is the uint16_t? do I have to put arrays to make it to a 3 Digit binary value?

keryll
Newbie Poster
3 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0594 seconds using 2.69MB