- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Read a binary file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2000 02:07 AM
05-02-2000 02:07 AM
Read a binary file
I need some help! I am trying to read a binary file in my HP-C program. Fopen
command does not distinguish between the binary and text files. So i have
decided to use a system command to tell HP that I am bringing in a binary file.
Is this the right way? If it is how do I convey my message using file command ?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2000 02:44 AM
05-02-2000 02:44 AM
Re: Read a binary file
"ascii file" or "binary file". The kernel doesn't care. It just opens the
file and delivers the bytes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2000 04:55 AM
05-02-2000 04:55 AM
Re: Read a binary file
fp=fopen("bxr27700.12r","r");
fscanf(fp,"hu\n",&s);/* reading a unsigned short integer*/
printf("%hu\n",s);
I get a value 0;
Once this works, I will be swapping bytes to convert to big-endian ( from
little endian).
Thanks for the help so far!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2000 06:04 AM
05-02-2000 06:04 AM
Re: Read a binary file
ascii to binary. This would appropriate if you were reading a tty to load a
value in a binary number.
In your case, no conversion is needed. You just want 2 bytes to be read.
Change your second line to:
fread(&s, sizeof s, 1, fp);
This will read the first two bytes of your file and store them in s. Use "od
-d" on your input file to verify the result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2000 07:22 AM
05-02-2000 07:22 AM
Re: Read a binary file
have a good night's sleep.