؟questions?

Thread Solved

Join Date: May 2008
Posts: 10
Reputation: xlx16 is an unknown quantity at this point 
Solved Threads: 0
xlx16 xlx16 is offline Offline
Newbie Poster

؟questions?

 
0
  #1
Dec 6th, 2008
hello again
i have three questions again:
how can i use malloc or calloc for a two demontional arrays?

is it true that A. calloc allocates memory in contiguous bytes, malloc does not ensure contiguous memory allocation?

the third question which is a bit irrelevent to programming
how memorey locations in computers are given address?i mean early intell CPUs could
onley address (64K) but what about the rest of memory locations?

thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: ؟questions?

 
0
  #2
Dec 6th, 2008
> is it true that A. calloc allocates memory in contiguous bytes, malloc does not ensure contiguous memory allocation?
No, it's false.
calloc is nothing more than malloc + memset to wipe the memory to all-bits-zero.

> i mean early intell CPUs could onley address (64K)
Only 64K in a single block.
If you wanted more, then you had to start messing about with segment registers
http://en.wikipedia.org/wiki/X86


> how can i use malloc or calloc for a two demontional arrays?
One (of several) ways
  1. char **arr = malloc( rows * sizeof *arr );
  2. for ( r = 0 ; r < rows ; r++ ) {
  3. arr[r] = malloc( cols * sizeof *arr[r] );
  4. }
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC