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 978381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:02:59+00:00 2026-05-16T04:02:59+00:00

I am working on an Operating Systems assignment for one of my summer classes.

  • 0

I am working on an Operating Systems assignment for one of my summer classes. The teacher has provided an object file that provides functions that mimic the behaviour of a disk device driver. We are then to write a file system API that uses the disk device driver in C.

I am working on my file system format function named Format() which calls a function named DevFormat() from the teachers object file. My function is supposed to return 1 if it was able to successfully format the file system and 0 otherwise. DevFormat() returns 1 if it was able to successfully format the disk drive and 0 otherwise. Here is come code:

int Format()
{
    if (!DevFormat())
    {
        printf("Disk drive wasn't formatted successfully\n");
        return 0;
    }

    <Do some stuff to the file system here>

    printf("File system successfully formatted\n");
    return 1;
}

My problem is that Format() just abruptly ends without returning a value. I have found that the offending piece of code is the line: if (!DevFormat()). Now I am writing the assignment in C but am using the GNU C++ (g++) compiler to compile and link my project as the teacher said we could. I want to say that the reason Format() abruptly ends when the line if (!DevFormat()) is executed has to do something with the compilers interpretation of my code (I could be way way off. Its just a guess.). I found that my function abruptly ends as well if I change the code to if (0 == DevFormat()). The only way I can test for failure is by assigning the return value of DevFormat() to an int variable and then checking that.

Any help would be much appreciated. Is it something to do with the way the C++ compiler interprets my code? Is it I missed something so mundane that I should be ashamed of myself?

Thanks again for the help.

  • 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-05-16T04:03:00+00:00Added an answer on May 16, 2026 at 4:03 am

    I think maybe you have forgotten the braces around your if statement – I imagine you meant to write this:

    if (!DevFormat()) {
        printf("Disk drive wasn't formatted successfully\n");
        return 0;
    }
    

    Only the printf statement was inside the if block, so the return statement was executed every time regardless of the return value of DevFormat(). That’s a common gotcha in C 🙂

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

Sidebar

Related Questions

For my Operating Systems class I have an assignment due that is built onto
I'm working on assignment for an operating systems class. We are given code to
In an operating systems course I took a while ago we were working on
I am working on a simple WCF service, MiniCalcService which has only one operation
I working my way through a C++ and Operating Systems book and I've come
I am working on an assignment for my Operating System class (Posix & C),
I'm working on a homework problem out of Stalling's Operating Systems: Internals and Design
We are working on a toy operating system as a assignment for a class.
I am working on a very large application that has multiple processes running simultaneously;
Different operating systems have different file name max lengths. Does Java have any limit

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.