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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:39:57+00:00 2026-05-25T11:39:57+00:00

I got it fixed. Thanks for all the help. I’ve now looked through quite

  • 0

I got it fixed. Thanks for all the help.

I’ve now looked through quite a few articles, forum posts and topics here; however, none have actually fixed my issue. The problem is that my fopen("file.txt", "w"); doesn’t create the file.

Code:

//
//Includes
#include <stdio.h>

int main ()
{
    FILE *receipt = fopen("receipt.txt", "w");

    //Create file
    fprintf(receipt, "Price: %.2f$", purchase);
    fprintf(receipt, "\nDiscount: %.2f$", discount);
    fprintf(receipt, "\nTax %%: %.2f%%", tax_pct);
    fprintf(receipt, "\nTaxes: %.2f$", tax);
    fprintf(receipt, "\nTotal Price: %.2f$", end_price);
    fprintf(receipt, "\n\nEnd of Receipt.");
    fclose(receipt);

    return 0;
}

I’ve tried throwing in

if(!receipt) {
    printf("Error!");
}
else {
    fprintf(blabla);
}

But to no avail.

It simply does not create the file :/ Running in Xcode and on Mac. No warnings/notices or otherwise stuff to give me any idea of what is wrong.

*I tried adding system("pwd") to figure out if it didn’t save it where it should save it, but I have a hard time actually finding that directory (I don’t know if it’s temp, but even so the file should be there?). Obviously I wasn’t questioning the actual validity of the library, duh, implicit that it was the fopen I was using not giving me what I expected?

I can’t make perror give me any useful information. Everything would appear to work as it should; I just don’t get a file. Please avoid any more smartass comments, if you don’t want to help just don’t write.*

Also, I removed all code, but the actual fopen() and fprintf().

  • 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-25T11:39:58+00:00Added an answer on May 25, 2026 at 11:39 am

    Try perror. It’s possible you don’t have permissions or something like that.

    FILE *receipt = fopen("receipt.txt", "w");
    if (!receipt)
        perror("fopen");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I got the static error fixed. Now I am just trying to find
I've got a service running at a fixed location in the network, with a
I've got a RadGrid with a fixed height, which is the same that ten
Okay, so I've got a problem - and I'd love to have it fixed.
I wonder if someone can help me. I've got a console App which I
I got a div which is of fixed width and height: #containersimg { width:
This jsfiddle example is what i got right now, the principle works on a
I set up an svn repository, and got it all working. However, whenever I
UPDATE: NOW RESOLVED - Thanks everyone! Fix: I had a column named referred_by and
I've got two divs, we'll all them id=one and id=two for ease. There is

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.