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

  • Home
  • SEARCH
  • 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 3488210
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:14:35+00:00 2026-05-18T11:14:35+00:00

Never used fwrite(), so I’m not sure exactly what I’m doing wrong. I’m just

  • 0

Never used fwrite(), so I’m not sure exactly what I’m doing wrong. I’m just testing it now and all I want to do is try to write a single char out to a file until it reaches the end. The file I’m writing to is one I downloaded from my teacher’s website. When I check the properties of it, the type is only listed as “file”. It’s supposed to just be an empty 2MB file for us to write our code to (file system lab if anyone’s wondering). Here’s my code:

#include <stdio.h>
#include <string.h>
int main()
{
    char c;
    FILE *fp;   
    char testing[2] = {'c'};  

    fp = fopen("Drive2MB", "rw"); 

    fseek(fp, 0, SEEK_SET);     //make sure pointers at beginning of file
    while((c=fgetc(fp))!=EOF)
    {
        fwrite(testing, 1, sizeof(testing), fp);
        fseek(fp, 1, SEEK_CUR);  //increment pointer 1 byte
    }
    fclose(fp);
} 

When I run this, an error message pops up saying “Debug Assertion Failed!…Expression:(“Invalid file open mode”,0) and prints “The program ‘[3896] filesystem.exe: Native’ has exited with code 3 (0x3).”

  • 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-18T11:14:36+00:00Added an answer on May 18, 2026 at 11:14 am

    You have opened the file for reading (that’s what the r stands for in fopen("Drive2MB", "r");). You may not write to a file opened for reading.

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

Sidebar

Related Questions

I've never used CI tools before, but from what I've read, I'm not sure
Never used a cache like this before. The problem is that I want to
I've never used SOAP before and I'm sort of new to Python. I'm doing
I never used ruby before, I just wanted to play around with HAML and
I've never used any of the .NET generics in my work, but I understand
I have never used octal numbers in my code nor come across any code
I've never used the Global Temporary Tables however I have some questions how they
I've never used any kind of source control before although I understand the concept.
i have never used LINQ in any of my projects , i have always
I have never used virtualization, and am trying to get up to speed. My

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.