Home > Back-end >  O, C builderbuild program for open the file I/O restrictions
O, C builderbuild program for open the file I/O restrictions

Time:10-01

The c + + builderbuild program have open the file I/O restrictions?
Whether the FILE * or HANDLE, 40 to open a FILE, then open the FILE is failed, best not cb it elder sister ah, strives for the light,

CodePudding user response:

Failed to open the file returns the error code is?

CodePudding user response:

GetLastError returns 183

CodePudding user response:

ERROR_ALREADY_EXISTS error code of 183, is the file already exists. Are you open the file or create a file? You have open the file code issued to Chou Chou,

CodePudding user response:

The test code as follows, very simple, an error occurred when num==47
 
String strFile="D: \ \ Data \ ";
Int num=0;
Char chNum [20].
VectorWhile (true)
{
Sprintf (chNum, "% d", num);
Num++;
String TMP=strFile + string (chNum);
TMP +=". TXT ";
The FILE * fp=fopen (TMP) c_str (), "wt");
If (fp==NULL)
{
DWORD ErrorNo=GetLastError ();
Sprintf (chNum, % d \ "0", ErrorNo);
ShowMessage (chNum);
}
VFiles. Push_back (fp);
}

CodePudding user response:

C + + Builder, the default use fopen to open the file number is limited: FOPEN_MAX under 32 bit is usually 50 (actual less than 50, because there are stdin/stdout/stderr), can be under 64, 512.

Suggestions for Windows API: CreateFile to operation,

CodePudding user response:

VS didn't see this limitation, is there any way to break through the limits on c + + builder?
Windows Api without this restriction, 3 q

CodePudding user response:

GCC and VC compiler there are limits, the default may be 512, can pass _setmaxstdio () to change, in c + + Builder, I recommend that you use CreateFile

CodePudding user response:

Why is that? The great god,

CodePudding user response:

refer to the eighth floor IssueNo response:
why? The great god,


what? Why?
There is no _setmaxstdio c + + Builder () function

CodePudding user response:

Oh, I thought the API and what is the issue between the stdio