home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16749 < prev    next >
Encoding:
Text File  |  1992-11-18  |  1.3 KB  |  40 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!hobbes.physics.uiowa.edu!news.uiowa.edu!icaen!sbtaves
  3. From: sbtaves@icaen.uiowa.edu (Steven Bradley Taves)
  4. Subject: How to malloc an array of pointers?
  5. Message-ID: <1992Nov19.004950.9200@icaen.uiowa.edu>
  6. Sender: usenet@icaen.uiowa.edu (UseNet News daemon)
  7. Organization: Iowa Computer Aided Engineering Network, University of Iowa
  8. Distribution: usa
  9. Date: Thu, 19 Nov 1992 00:49:50 GMT
  10. Lines: 28
  11.  
  12. Hi all,
  13.  
  14.     I'd appreciate it if someone could tell me how I can allocate memory
  15. for an array of pointers and for the strings they will be pointing to.
  16.  
  17. I have  
  18.        char *Var[];
  19.  
  20. Normally for
  21.        char *Var;
  22. you do
  23.        Var=(char *)malloc(10*sizeof(char));
  24. for a string of 10 characters.
  25.  
  26. I want to allocate memory for 10 strings of ten characters.  Also, how
  27. do I allocate memory for the pointers themselves?
  28.  
  29. Thanks,
  30. Steve
  31.  
  32.  
  33. -- 
  34. ____________________________________________________________________
  35. "A boy he was tangled in his fight forever, a girl was missing
  36.  two fingers","How do they kill children, and why do I wanna die"
  37. -Throwing Muses 
  38. Got any news on The Breeders? Email me sbtaves@icaen.uiowa.edu
  39. --------------------------------------------------------------------
  40.