Linked Questions

32 votes
3 answers
28k views

Consider the following simplified code bellow. I want to extract some binary data/stream from a file and print it to the standard output in Hexadecimal format. I got extra 3 bytes 0xFFFFFF. What's ...
user.dz's user avatar
  • 1,052
8 votes
2 answers
14k views

In a sample c++ code I will open a file and print each char in hexa file has only 16 chars but why ffffff will print after each heax values? char buff[256]; // buff filled with fread for(i=0;i<16;...
Syedsma's user avatar
  • 1,283
3 votes
3 answers
1k views

Code char a; a = 0xf1; printf("%x\n", a); Output fffffff1 printf() show 4 bytes, that exactly we have one byte in a. What is the reason of this misbehavior? How can I correct it?
EsmaeelE's user avatar
  • 2,755
2 votes
2 answers
1k views

I was trying to work on something and I basically have two questions. When creating a signed char, how do you a) what is the convention of initialization and print statement used to print it in ...
Trideep's user avatar
  • 61
2 votes
2 answers
764 views

I'm following a tutorial to write an emulator for the Chip8. Opcodes are 2 bytes long and in HEX. They are stored in unsigned short data types (which is 2 bytes). I want to get the last byte off of ...
Leon's user avatar
  • 31
-1 votes
2 answers
432 views

Consider: int x=0xdeadbeef; char c=x; printf("%x",c); The output is ffffffef. How? Why is it NOT 000000ef?
Febin Sunny's user avatar
1 vote
1 answer
675 views

I try to read binary(executeable) files, butsome problem as it prints extra character(0xffffff) after every few bytes. But this code work perfectly for text file(Non-binary). The code is: int main(...
superstack's user avatar
3 votes
1 answer
200 views

I was trying to write a function in C to print out the hexadecimal representation of a generic data type value. My first attempt was failed, the second succeeded, why? First attempt #include <...
user avatar
0 votes
3 answers
261 views

I want to send some 8 bit data(in HEX format) out of 16 bit data from my buffer using char ptr, so for this purpose I took "Unsigned short int" array and dereferencing it using char.But in ...
Sanith369's user avatar
0 votes
0 answers
217 views

int data = 0x69bd2ab7; char byte1 = (data >> 16) & 0x000000FF; printf("Extracted: 0x%x\n", byte1); The above prints: Extracted: 0xffffffbd How do I get rid of the prepended ff's and print ...
Kat's user avatar
  • 1
0 votes
1 answer
101 views

I was trying a basic program to copy elements form one array to another. The source array is having more elements. While copying elements from source to destination i only copy few elements from ...
Devjeet Mandal's user avatar
1 vote
1 answer
109 views

Hi I have written a program to toggle bits in char array. I found that when I am toggling the 7th bit I am getting wrong answer. Please help me. int main() { int n,c; char dummy; scanf("%...
Damodharan_C's user avatar
0 votes
0 answers
39 views

I am studying the IEEE 754 that stipulates 4 types floating-point number, formatted, unformatted, infinity and NAN. In my C program, I test what will happen if dividing 0 and print the bytes of the ...
Harrison Lee's user avatar
0 votes
0 answers
21 views

I am writing a simple program that reads data from two files and performs a byte-by-byte comparison to find the first(if any) difference between the two. Here is the code I'm having trouble with: it ...
OldIslander's user avatar
20 votes
4 answers
49k views

Say I want to print unsigned char: unsigned char x = 12; which is correct. This: printf("%d",x); or this: printf("%u",x); ? The thing is elsewhere on SO I encountered such discussion: -Even with ...
user avatar

15 30 50 per page