Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8965263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:46:19+00:00 2026-06-15T16:46:19+00:00

So given a binary file containing 100 bytes. I’m pretty sure that the INVALID

  • 0

So given a binary file containing 100 bytes. I’m pretty sure that the INVALID ones should cause and error, but why doesn’t it? I’m confused the once in INVALID should bring up a semantic error right? Or am I misunderstanding something

/* VALID */  fseek(fp, sizeof(char) * 2, SEEK_SET);
/* VALID */  fseek(fp, -2 * sizeof(char), SEEK_END);
/* INVALID */fseek(fp, sizeof(char)* 2, SEEK_END);
/* INVALID */fseek(fp, -2 * sizeof(char), SEEK_SET);
/* INVALID */fseek(fp, 50, SEEK_CUR);
/* VALID */  fseek(fp, -50, SEEK_CUR);
/* INVALID */ fseek(fp, 51, SEEK_CUR);
/* INVALID */ fseek(fp, -51, SEEK_CUR);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:46:20+00:00Added an answer on June 15, 2026 at 4:46 pm

    What “semantic error” are you talking about?

    Invalid file position will cause fseek to fail, which will be indicated by the return value of fseek. You have to receive that value and analyze it to determine whether the function succeeded or not. Your code above completely ignores the return value of fseek.

    Keep in mind that the standard library does not require all platforms to support SEEK_END positioning. The platform might not know where exactly the end of file is (until you actually bump into it while reading the file). For example, some file systems might not store the exact file size in bytes, but rather store how many “blocks” or “sectors” that file occupies, which can only serve as approximate file size. For this reason the language specification states that SEEK_END positioning is not guaranteed to be meaningfully supported.

    Also keep in mind that one some platforms it might be perfectly allowable to seek past the end of file opened for writing. The subsequent write operation will write data at the new position, while filling the “gap” with zeros.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a really large, 3+ gig, binary file is there anyway that I could
Given the path of a file (e.g. C:\MyPicture.jpg), how do I convert a binary
I need to validate whether the given binary is a PE file or not
I need to check whether given binary file has write access or not. File
I have a requirement where the file should be split using a given character.
Question from Programming Pearls, 2nd edition: Given a sequential file containing 4,300,000,000 32-bit integers,
I am reading book on programming pearls. Question: Given a sequential file that contains
Im trying to get this remote binary file to read the bytes, which (of
Given a binary file compiled with OCaml, is there a way to find out
this code given bellow will read a binary file and simply visualize the map

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.