There are so many iteration perform by loop,you design that is the main causes of your program crash or loop dead infinity.
Answer to what you expect to know is very complex because of some key notes---->>
1. It depends on the platform that the program is working on like
windows, linux or mac. I THINK that the amount of memory is not limited
by anything, but physical memory.
Fact-> Although physical memory is Might be extended by Virtual memory, Not all platforms has feature of 'virtual memory'.
C has no concept of virtual memory.
Malloc allocates contiguous memory (meaning side by side or together in ram).
So, it depends on the way platform handles the request. It depends upon the C implementation.
2. The largest number (in bytes) representable by standard type 'size_t' (declared by ). This value can and does vary among implementations. Note that this value isn't necessarily as large as the host(i.e. end user) platform's available memory.
QUES. Is there any limitation on that? Where am I supposed to get
this kind of information?
Ans. Malloc's argument is a size_t and the range of that type is [0,SIZE_MAX], so the maximum you can request is SIZE_MAX, which value varies from implementation to implementation and is defined in .
Note:- Whether a request for SIZE_MAX bytes will succeed depends on factors outside of the scope of this group.
malloc()
, so you're not achieving what you want. "how much memory is really being allocated in this example?" --> probably none. – Determinemalloc
returnsNULL
. Now you know (more or less) how much memory you can allocate on your system. – Blameless1
is not a prime number. – Carrara