c - Storing the lowest level bits and returning a char -


I am working on assignments that decode hidden messages stored in a ppm format picture. The first thing I need to do is the length of the message, which is hidden in a byte spread over 8 data bytes before the picture. After I have this, my argument is to make a method where I have a loop that changes bits 7 spots, first records one, and when there are 8 bits, then returning four representing them . So right now I am trying to understand how it will work. I was trying to get the value for the length of the hidden message I have tried to manually see how the behavior of all the bits happened. fgets (str, 64, fp); Four lengths [7]; Length [0] = str [7]; Length [1] = str [15]; Length [2] = str [23]; Length [3] = str [31]; Length [4] = str [39]; Length [5] = str [47]; Length [6] = str [55]; Length [7] = str [63]; printf (length);

So when the minimum level of length 8 bytes is hidden in bit i fgets (str, 64, fp); And then every 8th value is stored in an array. It gives "enpm0dp" when I changed the array to int, then the output was an arrow.

Can anyone tell me how to store bits in a byte and then match this value? Do I use an array of 8 bits? Or stored them in a string?

You think that fgets () calculates the length in the bits (64 for 8 bytes), but it's not really; See it is counted in characters.

After this, you think that the str is bits of bits, but arrays of bits are not present in C.

You have to consider an array of characters, which we will consider bytes:

  unsigned char letters [8]; If (fgets (str, sizeof str, fp)) {unsigned char length = 0, i; For (i = 0; i  & Gt; = 1; Length | = Str [i] & amp; 0x80; }}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -