I am relatively new to 'C' and would appreciate some insight on this topic.
Basically, I am trying to create a 16 MB array and check if the memory content is initialized to zero or '\0' or some garbage value for a school project.
Something like this:
char buffer[16*1024*1024];
I know there is a limit on the size of the program stack and obviously I get a segmentation fault. Can this somehow be done using malloc()?
You can initialize the memory with malloc like so:
You can then check the values in memory so (note that this will print for a very very long time):
Don't forget to free the memory when finished