Discussion Overview
The discussion revolves around the allocation of memory for a data type of char*** in C, particularly in the context of handling an array of strings. Participants explore the necessity of using three levels of indirection and the implications of such a choice.
Discussion Character
- Technical explanation
- Debate/contested
Main Points Raised
- Some participants question the need for a char*** type, suggesting that a char** may suffice for an array of strings.
- Example code is provided for allocating memory for char***, but some participants note issues with the code, such as missing variable assignments.
- There is a suggestion that the original poster might be trying to create a matrix-like structure, where char** represents rows of strings.
- Participants discuss the practice of casting the return value of malloc(), with some arguing it is unnecessary while others advocate for it as good practice.
- Some participants reference the C standard regarding void pointers and the casting of malloc(), noting that while casting is not required, it may be beneficial in certain contexts.
- There is speculation about the original poster's intent, with suggestions that the char*** could be pointing to multiple strings or even parts of a single string.
Areas of Agreement / Disagreement
Participants express differing views on the necessity and implications of using char***, with no consensus reached on the best approach or the original poster's intent.
Contextual Notes
Some participants highlight the potential dangers of using multiple levels of pointers, noting that it can complicate debugging. There are also discussions about the standards and practices surrounding memory allocation in C.
Who May Find This Useful
This discussion may be useful for programmers working with C who are dealing with complex data structures, particularly those involving dynamic memory allocation and pointer management.