Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Feb 1996 23:22:23 -0500 (EST)
From:      "Marc G. Fournier" <scrappy@ki.net>
To:        hackers@freebsd.org
Subject:   C Coding Question...
Message-ID:  <Pine.BSF.3.91.960209230838.4401A-100000@ki.net>

next in thread | raw e-mail | index | archive | help

Hi...

	I probably shouldn't send this here, but the only other place
I can think of is comp.lang.c, and I don't get that newsgroup :(  And
last time I checked out that group on another system...it was a bunch
of DOS users :(

	I've written some code, that, for the life of me, I can't figure
out why its giving me the results it is:

	The fragment of code looks like:

-----------------

  dblist *head, *temp;

  head = temp = get_dbrec("userid", "template", "advanced", "geoff");
    
  fprintf(stderr, "userid=%s\n", head->value);
    
  while(temp != NULL) {
    temp->value = get_valuer(content, temp->name);
    fprintf(tfile, "%-20s [%s]: %s [%s]\n", temp->name,
                                            head->name,
                                            temp->value,
                                            head->value);
    temp = temp->next;
  }

  fprintf(stderr, "userid=%s\n", head->value);

-----------------

	the structure dblist looks like:

typedef struct data {
        char *name;
        char *value;
        struct data *next;
        struct data *key;
} dblist;


	Now, get_dbrec() pulls a record out of a postgres95 database
file, and initialize a linked list of values...and it does this correctly.

	After initializing, head->value == "template", which is correct,
and what I'm expecting.

	When I run the code, the output looks like:

userid               [userid]: scrappy@ki.net [scrappy@ki.net]
fname                [userid]: Marc [Marc]
street               [userid]:  []
city                 [userid]:  []
state                [userid]:  []
phone                [userid]:  []
job                  [userid]: No Answer [No Answer]
terms                [userid]: Qualify [Qualify]
score                [userid]: 0 [0]
pcode                [userid]:  []
faxphone             [userid]:  []

	Which is where the problem is.  head->name, which points at the
beginning of the list, has the correct value in it all the way through
the while() loop, but for some reason, head->value keeps taking on the
new value, even though I'm not assigning it a new value anywhere, or
at least, not that I can figure out.  The value of 'head->value' *should*
remain as 'scrappy@ki.net', just like 'head->name' is 'userid'.

	I realize that I'm probably missing something *really* stupid, but
after working on this for 3 days and trying to figure out the problem, I'm
at a complete loss :(

	I also realize that there is probably incomplete data here as well,
but can't think of anything else to add :(

	Any ideas of where I should look, or what I'm missing?

	thanks...

Marc G. Fournier | POP Mail  Telnet Acct  DNS Hosting
System           |  WWW Services   Database Services  | Knowledge, 
  Administrator  |                                    | Information and
 scrappy@ki.net  |      WWW: http://www.ki.net        | Communications, Inc




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.960209230838.4401A-100000>