From owner-freebsd-hackers Fri Feb 9 20:22:17 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id UAA13698 for hackers-outgoing; Fri, 9 Feb 1996 20:22:17 -0800 (PST) Received: from ki.net (root@ki.net [142.77.249.8]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id UAA13668 for ; Fri, 9 Feb 1996 20:22:12 -0800 (PST) Received: (from scrappy@localhost) by ki.net (8.7.3/8.7.3) id XAA04609; Fri, 9 Feb 1996 23:22:24 -0500 (EST) Date: Fri, 9 Feb 1996 23:22:23 -0500 (EST) From: "Marc G. Fournier" To: hackers@freebsd.org Subject: C Coding Question... Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@freebsd.org Precedence: bulk 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