Reputation: 1329
Here is a very simple code
#include <stdio.h>
void main()
{
printf( "\n" );
printf( "%.512x", 0xFFFFFFFF );
printf( "\n" );
}
Problem is - I need a precision larger than 512 (print more then 512 symbols). But it looks like there is a limitation. If I replace 512 with any value that is larger - output result would not change.
I use Visual Studio 2008 and Windows XP.
Is there any way to avoid this limitation?
Upvotes: 0
Views: 114
Reputation: 4114
You can split it up into two or more parts (with each of them shorter than 512 symbols), for example by using the modulo operator. After splitting it up, you can use two printf()-commands for printing the number without the limitation.
Upvotes: 0
Reputation: 70502
The original ANSI C (C.89) standard only states:
The minimum value for the maximum number of characters produced by any conversion shall be 509.
Later versions (C.99 and C.11) extend this to 4095 bytes. So it seems your compiler is compliant to C.89.
As a workaround, you can just print out the number of 0
s you want ahead of the F
s, perhaps as a string.
char zeros[1000];
memset(zeros, '0', sizeof(zeros));
zeros[sizeof(zeros)-1] = '\0';
printf("\n%s%x\n", zeros, 0xFFFFFFFF);
Upvotes: 2