Problem with EMail Registration Code

From: RK (rlkm4@YAHOO.COM)
Date: 01/08/02

The original file is:

I am aware of the disclaimer at the top, but I can't  solve that
in the "2 hours" it said I could. I have ascii pfiles (so I know
I had to modify the loading of the character and whatnot and I did).
I added the appropriate char* as needed, but my problem goes down
to a few lines:
I rewrote (a little) how the file is supposed to be opened and
edited, but it still crashes.

Here is my code:
-- Start --
(the variables first, I still use global buffers..bpl17)
  FILE *fl;

(the code)
 sprintf(buf2, "reg.txt"); // for the filename
 fopen(buf2, "w");         // to create the "empty" file
 fl = fopen(buf2, "a");    // to append the "empty" file  (line 1981)
 fprintf(fl, "%s", buf);   // write the message w/ the password
 fclose(fl);               // close the file

-- End --

When I use GDB and BT after the crash, it says:
Program received signal SIGSEGV, Segmentation fault.
0x4009d0e4 in chunk_free (ar_ptr=0x40128a40, p=0x82a27b3) at malloc.c:3097
3097    malloc.c: No such file or directory.
(gdb) bt
#0  0x4009d0e4 in chunk_free (ar_ptr=0x40128a40, p=0x82a27b3) at
#1  0x4009ce6b in chunk_alloc (ar_ptr=0x40128a40, nb=184) at malloc.c:2594
#2  0x4009c670 in __libc_malloc (bytes=176) at malloc.c:2696
#3  0x40095d83 in _IO_new_fopen (filename=0x81933c0 "reg.txt",
    mode=0x80e8127 "a") at iofopen.c:42
#4  0x80900a2 in nanny (d=0x82f0428, arg=0xbffff8c0 "")
    at interpreter.c:1981

I've used fopen() in many many many other commands and never had this
problem. Obviously I'm doing something wrong, but I can't figure out
whats wrong.

Any suggestions or help? The mailing list has never had any previous
posts about this code.

   | FAQ: |
   | Archives: |
   | Newbie List:   |

This archive was generated by hypermail 2b30 : 06/25/03 PDT