printf

Discussion in 'C Programming' started by Shane, Jul 31, 2007.

  1. Shane

    Shane Guest

    Hi all, I am learning C, and I have a problem with printf.
    I have a pointer that points to binary data, and I want to print that data
    out. If I cast the pointer to (char *) then the data is printed out in the
    UniCode(?) equivalent of the data.
    If I try to cast to (int *) then I only get the address of the pointer (I
    think). What I really want is all the ones and zeros to be printed out.

    Any help appreciated
    TIA
    --
    Q: What's yellow and equivalent to the Axiom of Choice?
    A: Zorn's Lemon.
    Shane, Jul 31, 2007
    #1
    1. Advertising

  2. On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    wrote:

    >Hi all, I am learning C, and I have a problem with printf.
    >I have a pointer that points to binary data, and I want to print that data
    >out. If I cast the pointer to (char *) then the data is printed out in the
    >UniCode(?) equivalent of the data.
    >If I try to cast to (int *) then I only get the address of the pointer (I
    >think). What I really want is all the ones and zeros to be printed out.
    >


    What is the exact type of the pointer? "Binary data" is term that has
    had several different meanings in various posts. What does the
    pointer really point to? Give a short example if possible.


    Remove del for email
    Barry Schwarz, Jul 31, 2007
    #2
    1. Advertising

  3. Shane

    Shane Guest

    Barry Schwarz wrote:

    > On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    > wrote:
    >
    >>Hi all, I am learning C, and I have a problem with printf.
    >>I have a pointer that points to binary data, and I want to print that data
    >>out. If I cast the pointer to (char *) then the data is printed out in
    >>the UniCode(?) equivalent of the data.
    >>If I try to cast to (int *) then I only get the address of the pointer (I
    >>think). What I really want is all the ones and zeros to be printed out.
    >>

    >
    > What is the exact type of the pointer?


    Void

    > "Binary data" is term that has
    > had several different meanings in various posts. What does the
    > pointer really point to?


    Binary data, 1's and 0's
    I can interpret the data, if I can read it.

    > Give a short example if possible.
    >


    1111 1010 1100 1110

    >
    > Remove del for email


    --
    Q: What's yellow, normed, and complete?
    A: A Bananach space.
    Shane, Jul 31, 2007
    #3
  4. Shane

    dan Guest

    On Jul 30, 7:41 pm, Shane <-a-geek.net> wrote:
    > Barry Schwarz wrote:
    > > On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    > > wrote:

    >
    > >>Hi all, I am learning C, and I have a problem with printf.
    > >>I have a pointer that points to binary data, and I want to print that data
    > >>out. If I cast the pointer to (char *) then the data is printed out in
    > >>the UniCode(?) equivalent of the data.
    > >>If I try to cast to (int *) then I only get the address of the pointer (I
    > >>think). What I really want is all the ones and zeros to be printed out.

    >
    > > What is the exact type of the pointer?

    >
    > Void
    >
    > > "Binary data" is term that has
    > > had several different meanings in various posts. What does the
    > > pointer really point to?

    >
    > Binary data, 1's and 0's
    > I can interpret the data, if I can read it.
    >
    > > Give a short example if possible.

    >
    > 1111 1010 1100 1110
    >
    >
    >
    > > Remove del for email

    >
    > --
    > Q: What's yellow, normed, and complete?
    > A: A Bananach space.


    By example, I think Barry means an example program that can be
    compiled. Otherwise, nobody can understand what you're saying exactly.

    Daniel Goldman
    dan, Jul 31, 2007
    #4
  5. Shane

    Shane Guest

    dan wrote:

    > On Jul 30, 7:41 pm, Shane <-a-geek.net> wrote:
    >> Barry Schwarz wrote:
    >> > On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    >> > wrote:

    >>
    >> >>Hi all, I am learning C, and I have a problem with printf.
    >> >>I have a pointer that points to binary data, and I want to print that
    >> >>data
    >> >>out. If I cast the pointer to (char *) then the data is printed out in
    >> >>the UniCode(?) equivalent of the data.
    >> >>If I try to cast to (int *) then I only get the address of the pointer
    >> >>(I
    >> >>think). What I really want is all the ones and zeros to be printed
    >> >>out.

    >>
    >> > What is the exact type of the pointer?

    >>
    >> Void
    >>
    >> > "Binary data" is term that has
    >> > had several different meanings in various posts. What does the
    >> > pointer really point to?

    >>
    >> Binary data, 1's and 0's
    >> I can interpret the data, if I can read it.
    >>
    >> > Give a short example if possible.

    >>
    >> 1111 1010 1100 1110
    >>
    >>
    >>
    >> > Remove del for email

    >>
    >> --
    >> Q: What's yellow, normed, and complete?
    >> A: A Bananach space.

    >
    > By example, I think Barry means an example program that can be
    > compiled. Otherwise, nobody can understand what you're saying exactly.
    >
    > Daniel Goldman


    Ah, my mistake.

    Unfortunately I dont think any code I provide will clear things up further
    (The pointers are returned from librarys that arent, in my limited
    experince, well documented.)

    Suffice to say I have tried
    printf((char *)pointer_to_bin_data);
    and
    printf((int *)pointer_to_bin_data);

    I appreciate this is far less than what you are asking for, but is all I
    able to provide at this point.
    --
    Math problems? Call 1-800-[(10x)(13i)2]-[sin(xy)/2.362x].
    Shane, Jul 31, 2007
    #5
  6. Shane

    Ian Collins Guest

    Shane wrote:
    > Barry Schwarz wrote:
    >
    >> On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    >> wrote:
    >>
    >>> Hi all, I am learning C, and I have a problem with printf.
    >>> I have a pointer that points to binary data, and I want to print that data
    >>> out. If I cast the pointer to (char *) then the data is printed out in
    >>> the UniCode(?) equivalent of the data.
    >>> If I try to cast to (int *) then I only get the address of the pointer (I
    >>> think). What I really want is all the ones and zeros to be printed out.
    >>>

    >> What is the exact type of the pointer?

    >
    > Void
    >
    >> "Binary data" is term that has
    >> had several different meanings in various posts. What does the
    >> pointer really point to?

    >
    > Binary data, 1's and 0's
    > I can interpret the data, if I can read it.
    >
    >> Give a short example if possible.
    >>

    >
    > 1111 1010 1100 1110
    >

    That isn't a lot of help, is the data textual (does it look like the
    above in an editor), or raw data?

    If it is the former, you can probably just cast to char* and print it,
    otherwise you have to know the exact format of the data in oder to
    convert it into something meaningful.

    --
    Ian Collins.
    Ian Collins, Jul 31, 2007
    #6
  7. Shane

    Shane Guest

    Ian Collins wrote:

    > Shane wrote:
    >> Barry Schwarz wrote:
    >>
    >>> On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    >>> wrote:
    >>>
    >>>> Hi all, I am learning C, and I have a problem with printf.
    >>>> I have a pointer that points to binary data, and I want to print that
    >>>> data
    >>>> out. If I cast the pointer to (char *) then the data is printed out in
    >>>> the UniCode(?) equivalent of the data.
    >>>> If I try to cast to (int *) then I only get the address of the pointer
    >>>> (I
    >>>> think). What I really want is all the ones and zeros to be printed
    >>>> out.
    >>>>
    >>> What is the exact type of the pointer?

    >>
    >> Void
    >>
    >>> "Binary data" is term that has
    >>> had several different meanings in various posts. What does the
    >>> pointer really point to?

    >>
    >> Binary data, 1's and 0's
    >> I can interpret the data, if I can read it.
    >>
    >>> Give a short example if possible.
    >>>

    >>
    >> 1111 1010 1100 1110
    >>

    > That isn't a lot of help, is the data textual (does it look like the
    > above in an editor), or raw data?
    >
    > If it is the former, you can probably just cast to char* and print it,
    > otherwise you have to know the exact format of the data in oder to
    > convert it into something meaningful.
    >


    Hi
    from my OP
    >>>>" If I cast the pointer to (char *) then the data is printed out in
    >>>> the UniCode(?) equivalent of the data."


    Which isnt what I want.

    As far as I can tell the exact format of the data is bits, which, once I can
    see them, I am going to convert to something meaningful.

    --
    Q: What is very old, used by farmers, and obeys the fundamental theorem of
    arithmetic?
    A: An antique tractorisation domain.
    Shane, Jul 31, 2007
    #7
  8. Shane

    Ian Collins Guest

    Shane wrote:
    >
    > As far as I can tell the exact format of the data is bits, which, once I can
    > see them, I am going to convert to something meaningful.
    >

    Unless you know what the format is, how can you convert the data?

    --
    Ian Collins.
    Ian Collins, Jul 31, 2007
    #8
  9. Shane wrote:
    > Barry Schwarz wrote:
    >
    >> On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    >> wrote:
    >>
    >>> Hi all, I am learning C, and I have a problem with printf.
    >>> I have a pointer that points to binary data, and I want to print that data
    >>> out. If I cast the pointer to (char *) then the data is printed out in
    >>> the UniCode(?) equivalent of the data.
    >>> If I try to cast to (int *) then I only get the address of the pointer (I
    >>> think). What I really want is all the ones and zeros to be printed out.
    >>>

    >> What is the exact type of the pointer?

    >
    > Void
    >
    >> "Binary data" is term that has
    >> had several different meanings in various posts. What does the
    >> pointer really point to?

    >
    > Binary data, 1's and 0's
    > I can interpret the data, if I can read it.
    >
    >> Give a short example if possible.
    >>

    >
    > 1111 1010 1100 1110
    >


    If you know the length of the array, you may want to print each element
    (byte) of the array as an hex value.


    --
    Pietro Cerutti

    PGP Public Key:
    http://gahr.ch/pgp
    Pietro Cerutti, Jul 31, 2007
    #9
  10. Shane

    Shane Guest

    Ian Collins wrote:

    > Shane wrote:
    >>
    >> As far as I can tell the exact format of the data is bits, which, once I
    >> can see them, I am going to convert to something meaningful.
    >>

    > Unless you know what the format is, how can you convert the data?
    >


    Im missing something in the translation.

    The data is binary. Its a dump of a packet as received at eth0
    Once I can see the ones and zeros I can sort out the structure.

    --
    "The number you have dialed is imaginary. Please, rotate your phone by 90
    degrees and try again..."
    Shane, Jul 31, 2007
    #10
  11. Shane

    Mohan Guest

    On Jul 31, 10:54 am, Shane <-a-geek.net> wrote:
    > dan wrote:
    > > On Jul 30, 7:41 pm, Shane <-a-geek.net> wrote:
    > >> Barry Schwarz wrote:
    > >> > On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    > >> > wrote:

    >
    > >> >>Hi all, I am learning C, and I have a problem with printf.
    > >> >>I have a pointer that points to binary data, and I want to print that
    > >> >>data
    > >> >>out. If I cast the pointer to (char *) then the data is printed out in
    > >> >>the UniCode(?) equivalent of the data.
    > >> >>If I try to cast to (int *) then I only get the address of the pointer
    > >> >>(I
    > >> >>think). What I really want is all the ones and zeros to be printed
    > >> >>out.

    >
    > >> > What is the exact type of the pointer?

    >
    > >> Void

    >
    > >> > "Binary data" is term that has
    > >> > had several different meanings in various posts. What does the
    > >> > pointer really point to?

    >
    > >> Binary data, 1's and 0's
    > >> I can interpret the data, if I can read it.

    >
    > >> > Give a short example if possible.

    >
    > >> 1111 1010 1100 1110

    >
    > >> > Remove del for email

    >
    > >> --
    > >> Q: What's yellow, normed, and complete?
    > >> A: A Bananach space.

    >
    > > By example, I think Barry means an example program that can be
    > > compiled. Otherwise, nobody can understand what you're saying exactly.

    >
    > > Daniel Goldman

    >
    > Ah, my mistake.
    >
    > Unfortunately I dont think any code I provide will clear things up further
    > (The pointers are returned from librarys that arent, in my limited
    > experince, well documented.)
    >
    > Suffice to say I have tried
    > printf((char *)pointer_to_bin_data);
    > and
    > printf((int *)pointer_to_bin_data);
    >


    assuming you can dump data in hex:

    void xprint_binary_data (void *pointer_to_bin_data, int len)
    {
    unsigned int *t = (unsigned int *)pointer_to_bin_data;
    int i, ui_len = (len / sizeof (unsigned int));

    for (i = 0; i < ui_len; i++)
    {
    printf ("%8.8x ", t);
    if (i % 8 == 0) printf ("\n");
    }
    printf ("\n");
    }


    Mohan
    Mohan, Jul 31, 2007
    #11
  12. Shane

    Shane Guest

    Pietro Cerutti wrote:

    > Shane wrote:
    >> Barry Schwarz wrote:
    >>
    >>> On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    >>> wrote:
    >>>
    >>>> Hi all, I am learning C, and I have a problem with printf.
    >>>> I have a pointer that points to binary data, and I want to print that
    >>>> data
    >>>> out. If I cast the pointer to (char *) then the data is printed out in
    >>>> the UniCode(?) equivalent of the data.
    >>>> If I try to cast to (int *) then I only get the address of the pointer
    >>>> (I
    >>>> think). What I really want is all the ones and zeros to be printed
    >>>> out.
    >>>>
    >>> What is the exact type of the pointer?

    >>
    >> Void
    >>
    >>> "Binary data" is term that has
    >>> had several different meanings in various posts. What does the
    >>> pointer really point to?

    >>
    >> Binary data, 1's and 0's
    >> I can interpret the data, if I can read it.
    >>
    >>> Give a short example if possible.
    >>>

    >>
    >> 1111 1010 1100 1110
    >>

    >
    > If you know the length of the array, you may want to print each element
    > (byte) of the array as an hex value.
    >
    >


    Awesome, thats what I can do.
    How do I find the length of the array?
    --
    Math problems? Call 1-800-[(10x)(13i)2]-[sin(xy)/2.362x].
    Shane, Jul 31, 2007
    #12
  13. Shane

    Ian Collins Guest

    Shane wrote:
    > Ian Collins wrote:
    >
    >> Shane wrote:
    >>> As far as I can tell the exact format of the data is bits, which, once I
    >>> can see them, I am going to convert to something meaningful.
    >>>

    >> Unless you know what the format is, how can you convert the data?
    >>

    >
    > Im missing something in the translation.
    >
    > The data is binary. Its a dump of a packet as received at eth0
    > Once I can see the ones and zeros I can sort out the structure.
    >

    Then as other have suggested, dump it as hex. Or better still, use a
    decent packet snooper to log and dump the data.

    --
    Ian Collins.
    Ian Collins, Jul 31, 2007
    #13
  14. Shane <-a-geek.net> writes:
    [...]
    > Suffice to say I have tried
    > printf((char *)pointer_to_bin_data);
    > and
    > printf((int *)pointer_to_bin_data);


    I *hope* that didn't work.

    The first argument to printf is a format string (actually a pointer to
    a format string). The first call at least passes soething of the
    right type, but it's probably going to print whatever
    pointer_to_bin_data points to on stdout as raw binary data, up to the
    first '\0' character that it happens to see -- but if it happens to
    run across a '%' character, it's likely to interpret it as a directive
    and try to consume more arguments. Kaboom.

    The second call doesn't even pass the correct type. Your compiler
    should complain about it; if it doesn't, you probably forgot the
    required '#include <stdio.h>'.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Jul 31, 2007
    #14
  15. Shane said:

    > Hi all, I am learning C, and I have a problem with printf.
    > I have a pointer that points to binary data, and I want to print that
    > data
    > out.


    #include <stdio.h>
    #include <limits.h>

    void binprint(FILE *fp, void *vp, size_t n)
    {
    unsigned char *p = vp;
    unsigned char mask = 0;
    while(n--)
    {
    mask = 1 << (CHAR_BIT - 1);
    while(mask > 0)
    {
    putc('0' + ((*p & mask) != 0), fp);
    mask >>= 1;
    }
    ++p;
    }
    }

    /* driver */
    #include <time.h>

    int main(void)
    {
    int i = 42;
    double d = 3.1415926;
    time_t tt = time(NULL);
    struct tm *t = localtime(&tt);
    printf("int : "); binprint(stdout, &i, sizeof i); putchar('\n');
    printf("double : "); binprint(stdout, &d, sizeof d); putchar('\n');
    printf("struct tm: "); binprint(stdout, t, sizeof *t); putchar('\n');
    return 0;
    }

    Sample output:

    int : 00101010000000000000000000000000
    double : 0100101011011000000100100100110111111011001000010000100101000000
    struct tm: 0000101000000000000000000000000000011011000000000000000000000000000010000000000000000000000000000001111100000000000000000000000000000110000000000000000000000000011010110000000000000000000000000000001000000000000000000000000011010011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010101000100111110000010000001000

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    Richard Heathfield, Jul 31, 2007
    #15
  16. Shane wrote:
    > Pietro Cerutti wrote:
    >
    >> Shane wrote:
    >>> Barry Schwarz wrote:
    >>>
    >>>> On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    >>>> wrote:
    >>>>
    >>>>> Hi all, I am learning C, and I have a problem with printf.
    >>>>> I have a pointer that points to binary data, and I want to print that
    >>>>> data
    >>>>> out. If I cast the pointer to (char *) then the data is printed out in
    >>>>> the UniCode(?) equivalent of the data.
    >>>>> If I try to cast to (int *) then I only get the address of the pointer
    >>>>> (I
    >>>>> think). What I really want is all the ones and zeros to be printed
    >>>>> out.
    >>>>>
    >>>> What is the exact type of the pointer?
    >>> Void
    >>>
    >>>> "Binary data" is term that has
    >>>> had several different meanings in various posts. What does the
    >>>> pointer really point to?
    >>> Binary data, 1's and 0's
    >>> I can interpret the data, if I can read it.
    >>>
    >>>> Give a short example if possible.
    >>>>
    >>> 1111 1010 1100 1110
    >>>

    >> If you know the length of the array, you may want to print each element
    >> (byte) of the array as an hex value.
    >>
    >>

    >
    > Awesome, thats what I can do.
    > How do I find the length of the array?


    You can't. You have to keep track of it since the beginning (i.e. while
    storing data in it).

    --
    Pietro Cerutti

    PGP Public Key:
    http://gahr.ch/pgp
    Pietro Cerutti, Jul 31, 2007
    #16
  17. On Tue, 31 Jul 2007 15:41:12 +1200, Shane <-a-geek.net>
    wrote:

    >Barry Schwarz wrote:
    >
    >> On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    >> wrote:
    >>
    >>>Hi all, I am learning C, and I have a problem with printf.
    >>>I have a pointer that points to binary data, and I want to print that data
    >>>out. If I cast the pointer to (char *) then the data is printed out in
    >>>the UniCode(?) equivalent of the data.
    >>>If I try to cast to (int *) then I only get the address of the pointer (I
    >>>think). What I really want is all the ones and zeros to be printed out.
    >>>

    >>
    >> What is the exact type of the pointer?

    >
    >Void
    >
    >> "Binary data" is term that has
    >> had several different meanings in various posts. What does the
    >> pointer really point to?

    >
    >Binary data, 1's and 0's
    >I can interpret the data, if I can read it.
    >
    >> Give a short example if possible.
    >>

    >
    >1111 1010 1100 1110


    What is this?

    Is it the 19 characters in a string?

    Is it the binary representation of a 16 bit short? If so, is
    it little- or big-endian? If it is little-endian, is your data in
    memory order (so the value is 0xcefa) or does your data represent the
    value of the object (in this case 0xface)?

    Is it a 16-bit unicode character?

    We know binary data consist of ones and zeros. But the words one and
    zero have different meanings in different contexts. Give us the
    details of your data. What **exactly** does your void* point to?


    Remove del for email
    Barry Schwarz, Aug 1, 2007
    #17
  18. Shane

    Army1987 Guest

    On Tue, 31 Jul 2007 19:02:20 -0700, Barry Schwarz wrote:

    > On Tue, 31 Jul 2007 15:41:12 +1200, Shane <-a-geek.net>
    > wrote:
    >
    >>Barry Schwarz wrote:
    >>
    >>> On Tue, 31 Jul 2007 14:33:29 +1200, Shane <-a-geek.net>
    >>> wrote:
    >>>
    >>>>Hi all, I am learning C, and I have a problem with printf.
    >>>>I have a pointer that points to binary data, and I want to print that data
    >>>>out. If I cast the pointer to (char *) then the data is printed out in
    >>>>the UniCode(?) equivalent of the data.
    >>>>If I try to cast to (int *) then I only get the address of the pointer (I
    >>>>think). What I really want is all the ones and zeros to be printed out.
    >>>>
    >>>
    >>> What is the exact type of the pointer?

    >>
    >>Void
    >>
    >>> "Binary data" is term that has
    >>> had several different meanings in various posts. What does the
    >>> pointer really point to?

    >>
    >>Binary data, 1's and 0's
    >>I can interpret the data, if I can read it.
    >>
    >>> Give a short example if possible.
    >>>

    >>
    >>1111 1010 1100 1110

    >
    > What is this?
    >
    > Is it the 19 characters in a string?
    >
    > Is it the binary representation of a 16 bit short? If so, is
    > it little- or big-endian? If it is little-endian, is your data in
    > memory order (so the value is 0xcefa) or does your data represent the
    > value of the object (in this case 0xface)?
    >
    > Is it a 16-bit unicode character?
    >
    > We know binary data consist of ones and zeros. But the words one and
    > zero have different meanings in different contexts. Give us the
    > details of your data. What **exactly** does your void* point to?

    I think he just wants a raw representation of bits, if I
    understand him correctly. That is, *(unsigned char *)ptr is 0xFA
    and *((unsigned char *)ptr + 1) is 0xCE (assuming CHAR_BIT is 8),
    or *(unsigned char *)ptr is 0xFACE (assuming CHAR_BIT is 16). How
    many bytes he wants to print, that's another matter.
    --
    Army1987 (Replace "NOSPAM" with "email")
    "Never attribute to malice that which can be adequately explained
    by stupidity." -- R. J. Hanlon (?)
    Army1987, Aug 1, 2007
    #18
  19. Shane

    Shane Guest

    Ian Collins wrote:

    > Shane wrote:
    >> Ian Collins wrote:
    >>
    >>> Shane wrote:
    >>>> As far as I can tell the exact format of the data is bits, which, once
    >>>> I can see them, I am going to convert to something meaningful.
    >>>>
    >>> Unless you know what the format is, how can you convert the data?
    >>>

    >>
    >> Im missing something in the translation.
    >>
    >> The data is binary. Its a dump of a packet as received at eth0
    >> Once I can see the ones and zeros I can sort out the structure.
    >>

    > Then as other have suggested, dump it as hex. Or better still, use a
    > decent packet snooper to log and dump the data.
    >


    Hmm, well bright spark, how do you think those packet sniffers were written?

    --
    Q: What does a mathematician present to his fiancée when he wants to
    propose?
    A: A polynomial ring!
    Shane, Aug 3, 2007
    #19
  20. Shane

    Ian Collins Guest

    Shane wrote:
    > Ian Collins wrote:
    >
    >> Shane wrote:
    >>> Ian Collins wrote:
    >>>
    >>>> Shane wrote:
    >>>>> As far as I can tell the exact format of the data is bits, which, once
    >>>>> I can see them, I am going to convert to something meaningful.
    >>>>>
    >>>> Unless you know what the format is, how can you convert the data?
    >>>>
    >>> Im missing something in the translation.
    >>>
    >>> The data is binary. Its a dump of a packet as received at eth0
    >>> Once I can see the ones and zeros I can sort out the structure.
    >>>

    >> Then as other have suggested, dump it as hex. Or better still, use a
    >> decent packet snooper to log and dump the data.
    >>

    >
    > Hmm, well bright spark, how do you think those packet sniffers were written?
    >

    Long ago by people who knew what they were doing.

    --
    Ian Collins.
    Ian Collins, Aug 3, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Polite

    java printf

    Alex Polite, Jun 5, 2004, in forum: Java
    Replies:
    18
    Views:
    1,209
    Dale King
    Apr 15, 2006
  2. ben
    Replies:
    4
    Views:
    611
    Martin Ambuhl
    Jun 26, 2004
  3. whatluo

    (void) printf vs printf

    whatluo, May 26, 2005, in forum: C Programming
    Replies:
    29
    Views:
    1,237
  4. azza

    printf affects following printf/s

    azza, Oct 17, 2010, in forum: C Programming
    Replies:
    0
    Views:
    430
  5. guru
    Replies:
    8
    Views:
    276
Loading...

Share This Page