Hi
I am a student doing a project using C++ builder. I hava a problem in
opening a number of files more than 47, when run it only it create 46
file, Please help me to be able to create any number of files. Thanks
to your efforts.
Mohd Klaib
Example :
FILE *out[100];
char filename[100];
int noFiles=78;
for (int i=0 ; i<noFiles ; i++)
{
sprintf (filename,"c:/test/TestSuite%d",i) ;
out[i]= fopen(filename, "wt");
} 13 4857 mo*******@gmail .com wrote:
Hi
I am a student doing a project using C++ builder. I hava a problem in
opening a number of files more than 47, when run it only it create 46
file, Please help me to be able to create any number of files. Thanks
to your efforts.
Mohd Klaib
Example :
FILE *out[100];
char filename[100];
int noFiles=78;
for (int i=0 ; i<noFiles ; i++)
{
sprintf (filename,"c:/test/TestSuite%d",i) ;
out[i]= fopen(filename, "wt");
}
This looks more like a C problem.
There isn't a lot you can do if you have hit the number of open files
limit for your system. You would be better off asking on a platform
specific group.
--
Ian Collins. mo*******@gmail .com wrote:
Hi
I am a student doing a project using C++ builder. I hava a problem in
opening a number of files more than 47, when run it only it create 46
file, Please help me to be able to create any number of files. Thanks
to your efforts.
Mohd Klaib
Example :
FILE *out[100];
char filename[100];
int noFiles=78;
for (int i=0 ; i<noFiles ; i++)
{
sprintf (filename,"c:/test/TestSuite%d",i) ;
out[i]= fopen(filename, "wt");
}
Do you really have to have 78 files open *simultaneously *? That's hard
to believe. I suggest you operate on the files one at a time, and close
them when you are finished. Reorganise your code to do this.
john
On May 28, 9:00 am, John Harrison <john_androni.. .@hotmail.comwr ote:
mom.kl...@gmail .com wrote:
I am a student doing a project using C++ builder. I hava a problem in
opening a number of files more than 47, when run it only it create 46
file, Please help me to be able to create any number of files. Thanks
to your efforts.
Example :
FILE *out[100];
char filename[100];
int noFiles=78;
for (int i=0 ; i<noFiles ; i++)
{
sprintf (filename,"c:/test/TestSuite%d",i) ;
out[i]= fopen(filename, "wt");
}
Do you really have to have 78 files open *simultaneously *? That's hard
to believe.
For a student project, maybe, but there's nothing particularly
extraordinary for a server to have several hundred files open
simultaneously.
I suggest you operate on the files one at a time, and close
them when you are finished.
That would mean opening the files for each request, and closing
it at the end of the request. Which would slow things down
considerably, and wouldn't necessarily help, since different
threads (different client connections) will still access
different files.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
On 5ÔÂ28ÈÕ, ÏÂÎç2ʱ07·Ö, mom.kl...@gmail .com wrote:
Hi
I am a student doing a project using C++ builder. I hava a problem in
opening a number of files more than 47, when run it only it create 46
file, Please help me to be able to create any number of files. Thanks
to your efforts.
Mohd Klaib
Example :
FILE *out[100];
char filename[100];
int noFiles=78;
for (int i=0 ; i<noFiles ; i++)
{
sprintf (filename,"c:/test/TestSuite%d",i) ;
out[i]= fopen(filename, "wt");
}
Maybe you can use Windows API e.g. OpenFile(...). But I don't know how
much files can be opened simultaneously by this API.
On 5ÔÂ28ÈÕ, ÏÂÎç8ʱ01·Ö, kingfox <foxap...@gmail .comwrote:
On 5ÔÂ28ÈÕ, ÏÂÎç2ʱ07·Ö, mom.kl...@gmail .com wrote:
Hi
I am a student doing a project using C++ builder. I hava a problem in
opening a number of files more than 47, when run it only it create 46
file, Please help me to be able to create any number of files. Thanks
to your efforts.
Mohd Klaib
Example :
FILE *out[100];
char filename[100];
int noFiles=78;
for (int i=0 ; i<noFiles ; i++)
{
sprintf (filename,"c:/test/TestSuite%d",i) ;
out[i]= fopen(filename, "wt");
}
Maybe you can use Windows API e.g. OpenFile(...). But I don't know how
much files can be opened simultaneously by this API.- Òþ²Ø±»ÒýÓÃÎÄ×Ö -
- ÏÔʾÒýÓõÄÎÄ×Ö -
I just wrote a program to test how many files can be opened by Windows
API - OpenFile. This program open more than 5000 files simultaneously.
So I think OpenFile can fit your request. The program as below:
//--------------------------------------------------------------------------------------------------
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
#include <windows.h>
void closeFilesByAPI (HANDLE fileHandle)
{
CloseHandle(fil eHandle);
}
void howManyFilesCan BeOpenedByAPI()
{
vector<HANDLEha ndleVector;
HANDLE fileHandle;
int count = 0;
DWORD writtenBytes;
do {
stringstream fileName;
fileName.clear( );
fileName << "file" << count;
fileHandle = CreateFile(file Name.str().c_st r(), GENERIC_WRITE,
FILE_SHARE_WRIT E, NULL, CREATE_NEW, FILE_ATTRIBUTE_ NORMAL
+FILE_FLAG_RAND OM_ACCESS, NULL);
if (fileHandle == INVALID_HANDLE_ VALUE)
break;
handleVector.pu sh_back(fileHan dle);
WriteFile(fileH andle, fileName.str(). c_str(),
fileName.str(). size(), &writtenByte s, NULL);
cout << fileName.str() << '\r';
count ++;
}while(fileHand le != INVALID_HANDLE_ VALUE);
cout << "Total number of files opened by ofstream is: " << count <<
endl;
for_each(handle Vector.begin(), handleVector.en d(),
closeFilesByAPI );
}
//-------------------------------------------------------------------------------------------------- mo*******@gmail .com a écrit :
Hi
I am a student doing a project using C++ builder. I hava a problem in
opening a number of files more than 47, when run it only it create 46
file, Please help me to be able to create any number of files. Thanks
to your efforts.
You can have a look at the _NFILE defines in stdio.
It should give you the maximum number of file you can open with fopen.
Try to display errno and associated error with perror upon open failure.
It can help you identify the problem.
In your program:
sprintf (filename,"c:/test/TestSuite%d",i) ;
out[i]= fopen(filename, "wt");
if(out[i]<=0)
{//error
perror(filename );
}
Michael
In article <R5************ *****@newsfe7-gui.ntli.net>, jo************* @hotmail.com says...
[ ... ]
Do you really have to have 78 files open *simultaneously *? That's hard
to believe. I suggest you operate on the files one at a time, and close
them when you are finished. Reorganise your code to do this.
On many systems, opening or closing a file is a fairly expensive
operation, so this is likely to have a significant performance penalty.
It's technically off-topic, but most standard libraries I've looked at
had this limit set in a fairly easy-to-find definition. Adjust the
definition, re-compile the library, and you're off and running.
As long as we're off-topic: elsethread OpenFile was mentioned. MS
considers this obsolete, and new code is encouraged to use CreateFile
instead (though OpenFile probably isn't any more likely to disappear any
time soon than parts of C++ that have been deprecated...)
--
Later,
Jerry.
The universe is a figment of its own imagination.
On Mon, 28 May 2007 18:24:47 +1200, Ian Collins <ia******@hotma il.com>
wrote in comp.lang.c++: mo*******@gmail .com wrote:
Hi
I am a student doing a project using C++ builder. I hava a problem in
opening a number of files more than 47, when run it only it create 46
file, Please help me to be able to create any number of files. Thanks
to your efforts.
Mohd Klaib
Example :
FILE *out[100];
char filename[100];
int noFiles=78;
for (int i=0 ; i<noFiles ; i++)
{
sprintf (filename,"c:/test/TestSuite%d",i) ;
out[i]= fopen(filename, "wt");
}
This looks more like a C problem.
Looks like an obstructionist problem.
Wait, let me double check...
Yes, both sprintf() and fopen() are defined in the latest version of
the C++ standard.
In fact with addition of:
#include <cstdio>
#include <cstring>
using namespace std;
....and placement inside a suitable function, the user's snippet is
100% perfectly conforming standard C++ code.
Even with the addition of:
#include <stdio.h>
#include <string.h>
....the code is conforming, although deprecated.
There isn't a lot you can do if you have hit the number of open files
limit for your system. You would be better off asking on a platform
specific group.
Your advice is quite correct, but your comment is completely
incorrect. If you don't like using standard C++ library functions
that happen to be inherited from C, that's fine and dandy.
But no use of a function defined by the C++ standard is a "C problem".
Believe it or not, the C standard says absolutely nothing at all about
the behavior of fopen() or sprintf() in a C++ program. Anything and
everything in a C++ program is off-topic in C language groups.
The fact that C++ defines some functions with the same names as those
in the C library, and defines them to accept similar parameters and
return similar values, does not make them C functions when used in a
C++ program.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++ http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
On Mon, 28 May 2007 18:56:38 -0500, Jack Klein wrote:
Even with the addition of:
#include <stdio.h>
#include <string.h>
...the code is conforming, although deprecated.
Why should this be conforming? These are implementation specific header
files that need not work with anything but the specific C compiler they
are part of.
Of course in practice many vendors offer C and C++ compilers and design
there C system header files in such a way that they are compatible with
their C++ compiler but that is certainly not a requirement of either the
C or C++ standard.
--
Markus Schoder This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stephen |
last post by:
could someone give me some advise on a problem I have. At present i have a
web application which displays pdf files in a web browser using javascript
and the window.open method and pointing to a web address like
window.open(http://.........).
I have been asked to find out if it is possible to do something similar but
instead opening a file located on my web server e.g.(G:\psh-4.pdf). I would
like to be able to display the file in the web...
|
by: gary smith |
last post by:
I am trying to open a file (file --> open --> file) at an FTP location using
visual Studio.net. Unfortunately, I get an "unspecified error" alert
whenever I select a file.
Can anyone help explain why this should be the case.
Thanks
Gary
|
by: Murasama |
last post by:
Hi there,
Im trying a simple file IO operation in Visual Studio .NET 2003 and it
can't seem to open the file.
If I run the exe in the debug directory it works fine but if I click
the start button (blue arrow) then it fails to open the file.
any ideas?
source:
|
by: Charles Morrall |
last post by:
I have no experience with DB2 as such, but I've been tasked with configuring
backup of a server running DB2 v8 on Windows Server 2003. I do have some
experience with backups in general though. The backup software I'll be using
is Backup Exec 10, but Backup Exec doesn't have a specific agent for DB2, as
it does for SQL and Oracle. The supplier of Backup Exec claims I can use the
Open File option of Backup Exec to backup DB2.
I find this a...
|
by: nissiml |
last post by:
hi,
i'm trying to open a asp.net web page that list files from a Windows
application
like winword and select a file from it .
what do i have to do to make it happen, is it simple ?
Thanks in Advance.
| |
by: Mattbooty |
last post by:
Hello,
Not sure if anyone else has seen this bug, but I have a form where
the entire form is covered with a picturebox. The picturebox has a
mouseup event. I also have an open file dialog for loading images into
the picturebox. If you double click the file you want to open in the
open file dialog, it somehow interperets one of the clicks as a mouseup
on the picturebox and fires the mouseup event for the picturebox. How
can I get...
|
by: agphoto |
last post by:
There is big or problem in open file in read and write mode..
$file = "data.txt";
$fp = fopen($file,"w+");
$line = fgets($fp,"120"); // i need only 1st line to read and upto 120 bytes
echo $line;
fclose($fp);
coding is not problem, The problem is file modifier as mention in PHP
|
by: DyslexicAnaboko |
last post by:
Hello,
I have a module that is part of larger project that is giving me
trouble, so I setup an example.
Brief
=====
I simply want to open a text file and make the contents avaliable
through stdin that way a bourne shell script I wrote will execute
|
by: Ryan Liu |
last post by:
Hi,
Both way works, I'd just ask some experts which way is better?
My application creates a log file daily.
Now each time when I write a log, I will open the file and append to the
end. Ocz, if the file is not exist(e.g. another day), it will creates the
file first.
|
by: Coffee Pot |
last post by:
Thanks for any advice.
~ CP
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |