Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> > If after the above I created an array like so `char str[n]` and then assigned such that it pointed to the same region of memory that malloc() returned, then would the provenance of both pointer be equal?

> Yes.

Uh, no. This is flatly untrue. You cannot "assign an array such that it points to a region of memory". Arrays are not pointers, they do not point to anything.



I assumed they meant `char (*str)[5]`, ie a pointer to an array, because they wanted to reinterpret the malloc result as an array of the malloc'd length.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: