Hello to all there
I m new to this forum and couldnt find the answer to my question so I am creating new thread for discussion on this topic.
Recently I have taken some tests and one of many confusing question was this:
"Maximum possible number of nodes in a link list created in C is the maximum value of unsigned long integer. (True/False)"

well after thinking a lot I decided that it should be false there must be some way to make link list nodes unlimited to that number. I didnt get any reasonable and logical answer that make this statement true.

However someone said me that in C/C++ a pointer variable is allocated 4 Byte for holding the address and it automatically applies that there are fixed range of addresses that can be stored in any pointer value and as long integer is also 4 Byte so this reason makes above statement TRUE.

But this reason given to me made me more confuse that why the pointer value is allocated only 4 Bytes .

I believe that experts and professionals among you will provide the reasonable and logical explanation on this topic.

>> why the pointer value is allocated only 4 Bytes
Not necessarily -- depends on the operating system and the compiler. In the days of 16-bit MS-DOS pointers were 2 bytes. On 64-bit MS-Windows pointers are 8 bytes.

The maximum number of nodes in a linked list would be limited only by memory. True, you may not be able to count more nodes than can be stored in an unsigned long integer (on 32-bit computers) but the list could certainly hold many more nodes than that assuming there is enough memory.

The file limits.h gives the maximum values of many objects.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.