can u state the problem statement??
On Mon, Apr 25, 2011 at 3:43 AM, chase <[email protected]> wrote: > #include <stdint.h> > #include <stdio.h> > #include <stdlib.h> > int main(int argc, char *argv[]) { > // ensure proper usage > if (argc != 2) > return 1; > // open file > FILE *fp = fopen(argv[1], "r"); > if (fp == NULL) > return 1; > // seek to BITMAPFILEHEADER's bfSize > fseek(fp, 2, SEEK_SET); > // read in BITMAPFILEHEADER's bfSize > uint32_t bfSize; > fread(&bfSize, sizeof(bfSize), 1, fp); > // print bfSize > printf("\nbfSize: %d\n\n", bfSize); > // return to start of file rewind(fp); > // read in BITMAPFILEHEADER's raw bytes > uint8_t *buffer = malloc(14); > fread(buffer, 1, 14, fp); > // print field via cast > printf("bfSize: %d\n\n", *((uint32_t *) (buffer + 2))); > // print individual bytes in decimal > printf("bfSize: %d %d %d %d\n",buffer[2], buffer[3], buffer[4], > buffer[5]); > // print individual bytes in hexadecimal > printf("bfSize: 0x%x 0x%x 0x%x 0x%x\n",buffer[2], buffer[3], > buffer[4], buffer[5]); > // print individual bytes in binary > printf("bfSize: "); for (int i = 2; i < 6; i++) { > > for (int j = 7; j >= 0; j--) { > int mask = 1 << j; > if (buffer[i] & mask) > else > printf("1"); > printf("0"); > } > printf("\n\n"); > } > > > > > i did it for large.bmp and it gace me output :::: > > > > bfSize: 486 > > bfSize: 486 > > bfSize: 230 1 0 0 > bfSize: 0xe6 0x1 0x0 0x0 > bfSize: 11100110000000010000000000000000 > > > > > > but my QUESTION is i did in terminal: > > xxd -c 24 -g 3 large.bmp > > > and it gave me :: > > 0000000: 424de6 010000 000000 003600 000028 000000 0c0000 00f4ff > > > > HERE THE BFSIZE A/C TO ME IS e6 and it's dec. value is 230 > then why in 1st line it is giving output 486 . > > -- > You received this message because you are subscribed to the Google Groups > "google-codejam" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-code?hl=en. > > -- You received this message because you are subscribed to the Google Groups "google-codejam" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.
