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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:42:08+00:00 2026-06-18T17:42:08+00:00

I am new to programming and i have a problem where i u se

  • 0

I am new to programming and i have a problem where i u se and i need to make many files to write in >15 so i dont whant to do it manualy i used array of files. That works fine but the problem starts when i need to give a location of every file and by using a “for cyclus” i cant change the names of files in destinations here is part of code…

#include <stdio.h>
main()
{
int i;
FILE *files[14];
for(i=0;i<15;i++)
files[i]=fopen("C:\\File.txt" ,"w");
}
for(i=0;i<15;i++)
fclose(files[i]);
getch();
}

problem is with fopen function because it opens only 1st file, but not others…
if u need some more explaining please ask will try to provede as much as possible.. thanks

  • 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-18T17:42:09+00:00Added an answer on June 18, 2026 at 5:42 pm

    You’re only supplying one name, so instead of trying to open 15 files, you’re trying to open one file 15 times. Unless you specify a sharing mode, that will fail (at least with most compilers on Windows, which seems to be what you’re using).

    My guess is you want to open 15 different files though, in which case you need to specify 15 different file names. One possibility for doing that is to synthesize names that include the index. Since you appear to be using C (despite the c++ tag) I’ll stick to C for the moment.

    int i;
    FILE *f[15];
    
    for (i=0; i<15; i++) {
        char name[32];
    
        sprintf(name, "File%d.txt", i);
        f[i] = fopen(name, "w");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just new to programming in Unix and have a small issue that
I am new to programming. I have been trying to write a function in
I'm abit new to programming Android App's, however I have come across a problem,
I have a huge array of ints that I need to sort. The catch
I am new to VB programming and have come across an problem:( after a
I am fairly new to iOS programming and have run into a problem I
I'm new to Node.js and asynchronous programming in general, and I have a problem.
I'm new to python programming. I have this problem: I have a list of
I'm fairly new to programming C# and I have written a program that uses
Hi people iam new in programming objective-c for iOS. I have a big problem

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.