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