home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / c / 12228 < prev    next >
Encoding:
Text File  |  1992-08-12  |  1.8 KB  |  50 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!psinntp!commpost!opus!fia!camelot!jogulin
  3. From: jogulin@camelot.fia.dmg.ml.com (Joseph Ogulin)
  4. Subject: Re: Computer terms, etc
  5. Message-ID: <1992Aug11.122117.25826@fia.dmg.ml.com>
  6. Sender: jogulin@camelot (Joseph Ogulin)
  7. Nntp-Posting-Host: camelot
  8. Organization: The Rift from Here to There
  9. References:  <cee1.713424953@Isis.MsState.Edu>
  10. Date: Tue, 11 Aug 1992 12:21:17 GMT
  11. Lines: 37
  12.  
  13. In article <cee1.713424953@Isis.MsState.Edu>, cee1@ra.msstate.edu (Charles Evans) writes:
  14. |> If anyone could help me, please define these for me:
  15. |> and what is the diff. between  *foo[] and **foo?
  16.  
  17. I haven't experienced one, but *foo[] is an array of character pointers
  18. and **foo is a pointer to a character pointer.
  19.  
  20. |> whats the diff in these?
  21. |> 
  22. |> char *foo = "abc";
  23. |> char *foo[] = "abc";
  24.  
  25. What you have as *foo[] = "abc"; is an illegal declaration.  You would have
  26. to declare it as follows:
  27.  
  28.     char *foo[] = { "abc", 0 };
  29.  
  30. because you are declaring an array of pointers.  I can't recall if the 0 is
  31. necessary in there (somebody help, I don't do those declarations normally).
  32.  
  33. |> char foo[] = "abc";
  34. |> char foo[4] = "abc";  <--- is the '\0' autmatcially added?
  35.  
  36. Yes, the '\0' is automatically added, and there is nothing wrong with that
  37. declaration, however, it is not good practice because what happens when you
  38. want to change the string?  You have to be sure to change the size of the
  39. character array too.
  40.  
  41. -- 
  42. ==> "You never f**king know the answer when it's important." --The Doctor <==
  43. Joe Ogulin
  44.  
  45. jogulin@camelot.fia.dmg.ml.com        joe@monroe.pilot.dmg.ml.com
  46. jogulin@apollo.stevens-tech.edu        gcs_jogulin@stevens.bitnet
  47.  
  48. Disclaimer:  The above article is solely my opinion and does not necessar-
  49. ily reflect that of my employer.  The content is my responsibility alone.
  50.