Thread: Not displaying higher nibble

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    3

    Not displaying higher nibble

    I have this one array declared as result[row][col]

    the result[row][col] is obtained from the operation of array1[row][col] XOR (^) array2[row][col] where all the arrays contain hexadecimal numbers.


    After the result[row][col] is obtained, i want to display it in a form of 4x4 matrix. The function i have written is as follow :


    Code:
    void display(char result[4][4]){
    
    for(row = 0; row < 4; row ++){
    	for(col = 0; col < 4; col ++){
    	printf(" %x ", result[row][col]);}
    	printf("\n");         }
    
    }

    What i get from the display is of course, the expected value, except that it will not display 2 nibbles for a value of zero as its higher nibble.

    For e.g :

    the results[row][col] is supposedly to have this value :

    { 0xd6, 0xf3, 0x52, 0x04,
    0x00, 0x23, 0x5a, 0x53,
    0xc1, 0x0f, 0x3f, 0x66,
    0xa2, 0x06, 0x55, 0x7c}

    I am expecting this to be displayed on the screen :

    d6 f3 52 04
    00 23 5a 53
    c1 0f 3f 66
    a2 06 55 7c

    However, the actual display i get from the screen is

    d6 f3 52 4
    0 23 5a 53
    c1 f 3f 66
    a2 6 55 7c

    as you can see, those value with zero as its higher nibble will not be displayed and i dont want that to happens. What i want is to display a fixed 2 nibbles digits regardless its value and i could not find a way to do this. Please helps! Thank you very much!
    Last edited by gravityzer0; 08-20-2006 at 06:17 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 09:05 AM
  2. Need Help Displaying A Pattern.
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 10-05-2005, 11:01 AM
  3. Finding numbers higher than the first element in array
    By sonict in forum C++ Programming
    Replies: 2
    Last Post: 12-02-2002, 10:00 AM
  4. Need codes for displaying figures in descending mode.
    By rbaba in forum C++ Programming
    Replies: 0
    Last Post: 12-14-2001, 08:47 PM
  5. accessing lower nibble
    By arunksharma in forum C++ Programming
    Replies: 2
    Last Post: 11-17-2001, 03:07 AM