Re: viewing mbr os descriptor

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill Cunningham

    Re: viewing mbr os descriptor


    "Jens Thoms Toerring" <jt@toerring.de wrote in message
    news:69bghhF31l 8u3U1@mid.uni-berlin.de...
    Better make that
    >
    int main( void ) {
    >
    > int a;
    > FILE *fp;
    > fp=fopen("b","r b");
    >
    Are you sure the file got opened at all? I suspect that you
    want to open a file name "/b", not "b".
    No. I was just letting dd know to put the file "b" in the root
    directory.

    [snip]
    printf( "%x\n", ( unsigned int ) a );
    return 0;
    }
    Regards, Jens
    I have always read I think most from Richard Heathfield that good C code
    usually doesn't need casts. Or something to that effect. Is there a way to
    not need a cast here and use printf more knowledgably? Like using some of
    those #$][ characters that it takes to use to format data?

    Bill


  • Keith Thompson

    #2
    Re: viewing mbr os descriptor

    "Bill Cunningham" <nospam@nspam.c omwrites:
    "Jens Thoms Toerring" <jt@toerring.de wrote in message
    [...]
    > printf( "%x\n", ( unsigned int ) a );
    > return 0;
    >}
    >
    I have always read I think most from Richard Heathfield that good C code
    usually doesn't need casts. Or something to that effect. Is there a way to
    not need a cast here and use printf more knowledgably? Like using some of
    those #$][ characters that it takes to use to format data?
    Arguments to variadic functions (including printf) are one of the
    relatively rare cases where casts are often necessary and appropriate.
    In most cases, the compiler already knows the target type, and will
    generate an implicit conversion as needed. But in this case, the
    expected type (unsigned int) is determined by the format string
    ("%x"), not by the function's declaration. The compiler can't
    generally see the format string or use it to determine how to convert
    the argument (after all, the format string could be a variable rather
    than a literal).

    --
    Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

    Comment

    • CBFalconer

      #3
      Re: viewing mbr os descriptor

      Bill Cunningham wrote:
      "Jens Thoms Toerring" <jt@toerring.de wrote in message
      >
      >Better make that
      >>
      >int main( void ) {
      >>
      >> int a;
      >> FILE *fp;
      >> fp=fopen("b","r b");
      >>
      >Are you sure the file got opened at all? I suspect that you
      >want to open a file name "/b", not "b".
      >
      No. I was just letting dd know to put the file "b" in the root
      directory.
      >
      [snip]
      >
      > printf( "%x\n", ( unsigned int ) a );
      > return 0;
      >}
      >
      I have always read I think most from Richard Heathfield that good
      C code usually doesn't need casts. Or something to that effect.
      Is there a way to not need a cast here and use printf more
      knowledgably? Like using some of those #$][ characters that it
      takes to use to format data?
      As I pointed out earlier, this is OT on comp.programmin g. Please
      don't cross-post it there.

      --
      [mail]: Chuck F (cbfalconer at maineline dot net)
      [page]: <http://cbfalconer.home .att.net>
      Try the download section.


      ** Posted from http://www.teranews.com **

      Comment

      Working...