C Programming - Arrays - Discussion

Discussion Forum : Arrays - Yes / No Questions (Q.No. 1)
1.
A pointer to a block of memory is effectively same as an array
True
False
Answer: Option
Explanation:

Yes, It is possible to allocate a block of memory (of arbitrary size) at run-time, using the standard library's malloc function, and treat it as an array.

Discussion:
7 comments Page 1 of 1.

Dickby said:   9 years ago
As I know it does not have the same behavior as an array.

Try sizeof on an array and on a pointer. Can somebody explain why false is the wrong answer?

Anil said:   1 decade ago
int *p= (int*)malloc(n*sizeof (int));

But the answer is B. Because in arrays it is not possible to change the base address. But we can change here.

Dilini said:   1 decade ago
Can anyone submit a program of allocating a block of memory (of arbitrary size) at run time by using malloc function.

Sonu said:   4 years ago
Arrays have the same behaviour like a pointer.

Because pointer refers to address of next data similar as an array.

Abhishek said:   1 decade ago
Structure type variables are also block of memory, which is not the same as array. Can anyone explain this?

Vaishu said:   7 years ago
Can anyone please explain in detail?

Pooja chaurasia said:   1 decade ago
Can anyone explain it?

Post your comments here:

Your comments will be displayed after verification.