hi ,
how to write code to declare 6 arrays and each array can only has 4 characters of binary numbers .The binary numbers will be generated by random.
for example i need four arrays that consists:-
array1 has '0110'
array2 has '1000'
array3 has '0110'
array4 has '1000'
if i write
char array[6]
it prepares 6 arrays but each array can have more than 4 characters,
many thanks
declare array with specific characters
- stefan.filipovic
- mikroElektronika team
- Posts: 1135
- Joined: 18 Dec 2018 10:30
Re: declare array with specific characters
Hi,
I made an example project and examples of these functions you are referring to.
Please find the project in the attachment.
Kind regards,
I made an example project and examples of these functions you are referring to.
Please find the project in the attachment.
Kind regards,
- Attachments
-
- Example.zip
- (39.45 KiB) Downloaded 93 times
Stefan Filipović
Re: declare array with specific characters
Thank you Stefan.
your code of conversion to binary numbers worked well.
But after doing cross over, and i read back the decimal value after conversion and display to GLCD, it displayed unknown character.
i tried this code
do i need to write special conversion from binary to decimal using "pow" for each binary bits.
Many thanks Stefan
![Very Happy :D](./images/smilies/icon_biggrin.gif)
your code of conversion to binary numbers worked well.
But after doing cross over, and i read back the decimal value after conversion and display to GLCD, it displayed unknown character.
i tried this code
Code: Select all
.......................
int value;char txt;
....................
value=char1;
........................
Int To Str(value,txt);
Glcd_Write_Text(txt,77,7,2);
Many thanks Stefan
![Very Happy :D](./images/smilies/icon_biggrin.gif)
![Very Happy :D](./images/smilies/icon_biggrin.gif)
![Very Happy :D](./images/smilies/icon_biggrin.gif)
- stefan.filipovic
- mikroElektronika team
- Posts: 1135
- Joined: 18 Dec 2018 10:30
Re: declare array with specific characters
Hi,
I'm sorry but I'm afraid that I have not understood you correctly.
Could you please share the whole code which explains what you intended to do?
I understand that you want to display something on the GLCD, but I can't see exactly how you have been trying to do that.
Kind regards,
I'm sorry but I'm afraid that I have not understood you correctly.
Could you please share the whole code which explains what you intended to do?
I understand that you want to display something on the GLCD, but I can't see exactly how you have been trying to do that.
Kind regards,
Stefan Filipović
Re: declare array with specific characters
Thank you for your reply,
I meant after doing cross over/exhange bits , how do I finally display the final result in decimal not in binary?
Many thanks
I meant after doing cross over/exhange bits , how do I finally display the final result in decimal not in binary?
Many thanks
- stefan.filipovic
- mikroElektronika team
- Posts: 1135
- Joined: 18 Dec 2018 10:30
Re: declare array with specific characters
Hi,
If you want to convert a string with bits to the string with a decimal value, just call the function StrBitsToUChar from the project which I attached before, and after that call the function BytoToStr from the Conversions library, as shown below.
Kind regards,
If you want to convert a string with bits to the string with a decimal value, just call the function StrBitsToUChar from the project which I attached before, and after that call the function BytoToStr from the Conversions library, as shown below.
Code: Select all
unsigned char num1;
char array[] = "01010101";
StrBitsToUChar(array, &num1);
ByteToStr(num1, array);
Stefan Filipović