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

  1. Path: sparky!uunet!olivea!decwrl!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!jsanders
  2. From: jsanders@symcom.math.uiuc.edu (John Eric Sanders)
  3. Newsgroups: comp.lang.c
  4. Subject: Array of pointers to structures
  5. Message-ID: <Bt5Eq2.ExL@news.cso.uiuc.edu>
  6. Date: 17 Aug 92 22:06:00 GMT
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. Organization: Math Dept., University of Illinois at Urbana/Champaign
  9. Lines: 42
  10.  
  11. I am trying to create a text window that holds the log of some data
  12. coming in from an instrument and allow the user to scroll backwards
  13. to previous data (but not indeffinately, due to memory limitations).
  14. I am having some problems doing this, and could use some help from
  15. the net.c.gurus.
  16.  
  17. I think that this is the best way of doing it:
  18. I want to create an array of pointers to strings of length n.  The only
  19. way I have found to do this is to make a structure strig, defining it
  20. as a string 
  21.  
  22. struct strig 
  23. {  char elment[80]; } ;
  24.  
  25. I then make an array of pointers pointing to this structure.
  26.  
  27. struct strig *ptr[100];
  28.  
  29. The idea behind this is that I can shift the pointers in the array
  30. around, without having to move the actual strings in memory.
  31.  
  32. However, I can't seem to access a particular character, which I need to.
  33. For example, I want to access the 5th character of the 75th line of
  34. data, but *ptr[74].elment[4] = 'n' doesn't seem to work.  Should it?
  35. Do I have a bum compiler?  I was doing some tests and found that
  36. ptr[5]->elment[2] is not equal to (*ptr[5]).elment[2], like the book
  37. I have says it should be.
  38.  
  39. Am I totally off base here?  Can someone help me please?
  40. If you think that you can help, but can't understand the question
  41. because I have worded it so weirdly, e-mail for a (hopefully) better
  42. explanation.
  43.  
  44.  
  45. Reply by e-mail, please.
  46.  
  47. Thanx in advance
  48.  
  49. -- 
  50.  The Jester (John E. Sanders)       jsanders@symcom.math.uiuc.edu       
  51.  I have finally discovered the method to my madness.  Unfortunately,    
  52.  there is more madness to my method than method to my madness.          
  53.