James wrote:
> 
> Ok, i understand the need to make a pointer to the pointer so you can
> make the pointer point to some other pointer (ok, so i intentionally
> put lots of pointers in that line :) ) but here's what i'm trying to do:
> 

Be careful on using pointers in C , it can take you hours to find a
little bug. So keep it simple.
try the next code.


 typedef struct line_t line;
 struct line_t {
     char data[80];
     line *next;
 };
 
/* -- Start of actual source --*/
 
 #include <stdio.h>
 #include <string.h>

 
 void next_1 (line *in);
 
 void next_1 (line *in)
 {
     /* this is where i am having difficulties, gcc gives this error:
            passback.c:9: request for member `next' in something not a
structure
            or union */
         in = in->next;
        /* printf to test the pointer access */
         printf (" %s\n",in->data);
 }
 
 void main (void)
 {
     line *listy;
 
         listy = (line *) malloc (sizeof (line));
     strcpy (listy->data, "Hello");
     listy->next = (line *) malloc (sizeof (line));
     strcpy (listy->next->data, "Out There");
     listy->next->next = NULL;
     printf (%s",listy->data);
     next_1 (listy);
 
 }


> 
> anybody recommend a good Linux/unix C book? one that covers linux/unix related
> things like processes etc. I DO have the Linux programming man reference
> pages, however if you don't know the name of the function you're after, it's
> a bit hard to find what you need :) (some sort of contents page would have
> been useful)

As i am novice to Linux i use 'Beginning Linux Programming' from Wrox
Press
ISBN 1-874416-68-0. This book expect you to have some
experience on programming C, but i gives you a good
start for learning basic techniques for programming in
a Linux environment.

Other good titles are welcome.

Regards, Henk Jan

Reply via email to