Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why a pointer is needed in c programming?

0
Posted

Why a pointer is needed in c programming?

0

The C language has no implicit memory allocation and garbage collection, so when you allocate memory from the heap, you have use a malloc (or related) operation, and when you are done with the object, you have to free it up explicitly. To pass these objects around, you pass a pointer (or “reference” in other language terminologies) instead of the object itself. This makes passing large objects much faster, but there are inherent disadvantages to this as well. Also, the designers of C intertwined the notions of arrays and pointers to the point that an array reference is a convenient method of doing pointer arithmetic, and as such, array references can be rewritten as pointer arithmetic references. This made the language easier to design and implement, but I think it also added to the complexity of learning the language and maintaining source code written in it.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123