ID: Q115325
7.00 | 1.00 1.50 MS-DOS | WINDOWS kbtool kbbuglist
The information in this article applies to:
- Microsoft C/C++ for MS-DOS, version 7.0
- Microsoft Visual C++ for Windows, versions 1.0 and 1.5
The intrinsic version of the strlen() function fails for arrays larger than 65535 bytes. The compiler options needed to reproduce the problem are /Oi and /AL, as shown with the sample code in the "MORE INFORMATION" section of this article.
The problem can be worked around using one of the following methods:
-or-
-or-
-or-
-or-
Microsoft has confirmed this to be a bug in the products listed above. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
This is not a problem in Visual C++ 1.0, 32-bit Edition.
The following code can be used to demonstrate this problem:
/* Compile options needed: /Oi /AL
*/
#include <string.h>
#include <stdio.h>
// #pragma function(strlen) // This line needed to fix the problem
char _far sz65535[65536];
void main(void)
{
size_t length;
memset(sz65535, 'A', 65535U);
sz65535[65535] = '\0';
length = strlen( sz65535);
printf( "Actual Length of string is 65535,\n"
"strlen(sz65535) returned %u\n", length);
}
More information on #pragma can be found in the online Help for Visual C++ or by typing "qh #pragma" at the MS-DOS prompt in C/C++, version 7.0.
Additional reference words: 1.00 1.50 7.00 8.00 8.00c KBCategory: kbtool kbbuglist KBSubcategory: CLIss Keywords : kb16bitonly
Last Reviewed: July 23, 1997