Is an integer array that any C99 implementation can accept.
[...]
Yes, it is. Is that intended to be a response to the OP's question?
Are you under the impression that the OP is using a C99
implementation, or that he either tried to or should declare an array
of char?
I strongly suspect that the OP fell into the trap of conflating "int"
and "integer". It's an easy mistake to make. It's also an easy
mistake to point out in a straightforward manner. Perhaps that's what
you intended to do, but it's likely the OP is going to miss the
subtlety of your demonstration.
The OP needs to post the actual code and the actual error message.
Telling him that is just as easy as giving a response that assumes a
literal interpretation of the OP's words that are obviously
inconsistent with what he actually meant.
Using a little common sense now and then doesn't violate the
comp.lang.c topicality guidelines.
I understand what you're saying.
However, I think this biplab person is a troll. (Yes, I'm a bit
paranoid, but that's what his previous messages suggest)
I wanted to see his reply to my post to figure out if he's indeed a
troll or legitimate.
As for C99, he said "I'm using TC 3.0". I have no idea what that is,
but I thought maybe he's referring to technical corrigendum 3. (though
unlikely)
Regardless, here's a more "complete" answer...
In C90, it's impossible to have such array in every implementation.
Keep in mind, 162 * 219 = 35478
Environmental limits allow any conforming C90 implementation to fail
to translate a program if its source code has an object that is larger
than 32767 bytes.
~(size_t)0 is guaranteed to be equal or greater than 32767.
(note I'm using ~(size_t)0 since there is no SIZE_MAX in C90)
So malloc(35478) might not allocate an object of 35478 bytes, if
~(size_t)0 is equal to 32767.
Instead, it will allocate 35478 - 32767 - 1 bytes. (2710)
In C99, SIZE_MAX in <limits.h> is equal to ~(size_t)0. It's equal or
greater than 65535.
If by integer you meant int, you can have
int array[35478];
*ONLY* if sizeof (int) == 1, which is quite unlikely for most
implementations.
You can do something like this in C99:
#include <limits.h>
#if SIZE_MAX < ULONG_MAX
# error not enough resources
#endif
/* ... */
Then use malloc. (just because SIZE_MAX is greater than the suggested
environmental limit by the standard does not mean the implementation
must allow objects that large)
Since you want an array so big, you might want to conform to another
standard instead of ISO C, such as POSIX of windows C. (is there such
standard anyway? windows C programming...)
Those are off-topic for comp.lang.c by the way.