Newsgroups: comp.lang.c Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!bronze!silver!mitchemt From: mitchemt@silver.ucs.indiana.edu (Terry Mitchem) Subject: pointer problems, help! Message-ID: <1991Mar22.082225.24948@bronze.ucs.indiana.edu> Sender: news@bronze.ucs.indiana.edu (USENET News System) Organization: Indiana University, Bloomington Distribution: na Date: Fri, 22 Mar 91 08:22:25 GMT Lines: 55 I am having some major problems getting a piece of code to work. It seems that everytime I change the contents of one string, it affects another one. For example, when I build the filename below, it gets wiped out when I null the members of "target_player". The code is below, and below that is the datafile I am using. void edit_category() { struct { char *card_number; char *quantity; char *first_name; char *last_name; char *price_mint; char *price_ex; } target_player; char filename[80],carriage_return[5]; int infile,bytes; *filename=NULL; strcat(filename,".\\"); strcat(filename,category.brand); strcat(filename,"\\"); strcat(filename,category.type); strcat(filename,"\\"); strcat(filename,category.year); strcat(filename,"\\"); strcat(filename,category.other); strcat(filename,"\\data"); *target_player.card_number=NULL; *target_player.quantity=NULL; *target_player.first_name=NULL; *target_player.last_name=NULL; *target_player.price_mint=NULL; *target_player.price_ex=NULL; infile=open(filename,O_RDONLY); if (infile==-1) exit(1); read(infile,target_player.card_number,5); read(infile,target_player.quantity,3); read(infile,target_player.first_name,21); read(infile,target_player.last_name,21); read(infile,target_player.price_mint,7); read(infile,target_player.price_ex,7); } ---------------------------------------------------------------------------- Here is the datafile: 8 2 joe montana .75 .40 9 2 christian okoye .20 .10 Any and all help is appreciated. I don't seem to be able to get anything useful out of K&R to help me. I am compiling with turbo-c. Thanks in advance Terry