<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Read a binary file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/read-a-binary-file/m-p/2422486#M766971</link>
    <description>Thanks Paul, it worked, at last. Your help is very much appreciated. Now, I can &lt;BR /&gt;have a good night's sleep.</description>
    <pubDate>Tue, 02 May 2000 14:22:58 GMT</pubDate>
    <dc:creator>Mokkarala Prakash</dc:creator>
    <dc:date>2000-05-02T14:22:58Z</dc:date>
    <item>
      <title>Read a binary file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-a-binary-file/m-p/2422482#M766967</link>
      <description>Hi folks,&lt;BR /&gt;&lt;BR /&gt;I need some help! I am trying to read a binary file in my HP-C program. Fopen &lt;BR /&gt;command does not distinguish between the binary and text files. So i have &lt;BR /&gt;decided to use a system command to tell HP that I am bringing in a binary file. &lt;BR /&gt;Is this the right way? If it is how do I convey my message using file command ?&lt;BR /&gt;Thanks.</description>
      <pubDate>Tue, 02 May 2000 09:07:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-a-binary-file/m-p/2422482#M766967</guid>
      <dc:creator>Mokkarala Prakash</dc:creator>
      <dc:date>2000-05-02T09:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Read a binary file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-a-binary-file/m-p/2422483#M766968</link>
      <description>Just use fopen.  There is no way to inform the kernel that the file is an &lt;BR /&gt;"ascii file" or "binary file".  The kernel doesn't care.  It just opens the &lt;BR /&gt;file and delivers the bytes.</description>
      <pubDate>Tue, 02 May 2000 09:44:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-a-binary-file/m-p/2422483#M766968</guid>
      <dc:creator>Paul Hite_2</dc:creator>
      <dc:date>2000-05-02T09:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Read a binary file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-a-binary-file/m-p/2422484#M766969</link>
      <description>I still can't get the value I am supposed to; This is what I am doing:&lt;BR /&gt;&lt;BR /&gt;fp=fopen("bxr27700.12r","r");&lt;BR /&gt;fscanf(fp,"hu\n",&amp;amp;s);/* reading a unsigned short integer*/&lt;BR /&gt;printf("%hu\n",s);&lt;BR /&gt;&lt;BR /&gt;I get a value 0; &lt;BR /&gt;&lt;BR /&gt;Once this works, I will be swapping bytes to convert to big-endian ( from &lt;BR /&gt;little endian). &lt;BR /&gt;Thanks for the help so far!</description>
      <pubDate>Tue, 02 May 2000 11:55:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-a-binary-file/m-p/2422484#M766969</guid>
      <dc:creator>Mokkarala Prakash</dc:creator>
      <dc:date>2000-05-02T11:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Read a binary file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-a-binary-file/m-p/2422485#M766970</link>
      <description>fscanf is a function, which, as you have used it, is going to try to convert &lt;BR /&gt;ascii to binary.  This would appropriate if you were reading a tty to load a &lt;BR /&gt;value in a binary number.  &lt;BR /&gt;&lt;BR /&gt;In your case, no conversion is needed.  You just want 2 bytes to be read.  &lt;BR /&gt;Change your second line to:&lt;BR /&gt;&lt;BR /&gt;fread(&amp;amp;s, sizeof s, 1, fp);&lt;BR /&gt;&lt;BR /&gt;This will read the first two bytes of your file and store them in s.  Use "od &lt;BR /&gt;-d" on your input file to verify the result.</description>
      <pubDate>Tue, 02 May 2000 13:04:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-a-binary-file/m-p/2422485#M766970</guid>
      <dc:creator>Paul Hite_2</dc:creator>
      <dc:date>2000-05-02T13:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Read a binary file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-a-binary-file/m-p/2422486#M766971</link>
      <description>Thanks Paul, it worked, at last. Your help is very much appreciated. Now, I can &lt;BR /&gt;have a good night's sleep.</description>
      <pubDate>Tue, 02 May 2000 14:22:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-a-binary-file/m-p/2422486#M766971</guid>
      <dc:creator>Mokkarala Prakash</dc:creator>
      <dc:date>2000-05-02T14:22:58Z</dc:date>
    </item>
  </channel>
</rss>

