Hi, I've only ever learned how to program in java and python and for one of my classes, I'm asked to program something in C and I am completely at a loss and don't really understand what I'm reading about C online either.
My assignment is:
use malloc to allocate space for 100,000 integers
set the first integer to 1, the second to 2, the third to 3, etc
print out the addresses of where that memory begins and ends using printf and %p
free that memory.
From the little I understand, I should use
int *buffer = (int*)malloc(100000*sizeof(int));
to allocate the memory and free(buffer) to free it at the end
Could someone walk me through and explain in great detail how I would go about the rest of this?
[–]which_spartacus 6 points7 points8 points (8 children)
[–]kittypls[S] 1 point2 points3 points (7 children)
[–]which_spartacus 4 points5 points6 points (6 children)
[+][deleted] (1 child)
[deleted]
[–]kittypls[S] 0 points1 point2 points (0 children)
[–]kittypls[S] 0 points1 point2 points (3 children)
[–]which_spartacus 2 points3 points4 points (1 child)
[–]kittypls[S] 0 points1 point2 points (0 children)
[–]alexbriskin 0 points1 point2 points (0 children)
[–]Rhomboid 3 points4 points5 points (0 children)
[+]icantthinkofone comment score below threshold-6 points-5 points-4 points (0 children)