code problem

This is a discussion on code problem within the C Programming forums, part of the General Programming Boards category; hi, this code of mine works fine. Only thing is that when i add a new entry(not modify) windows xp ...

code problem

hi, this code of mine works fine. Only thing is that when i add a new entry(not modify) windows xp brings this error message that the .exe file has caused an error, would you like to send an error message. I have tried compiling on two machines with 2 diff compilers, with the same results. could you guys help me debug it??? the tbfile is any text file that you can create with notepad. thanks a bunch

Here's my version of your insert function. It's different to yours, see how you get on with it. I haven't compiled it, and can't guarantee it will work, but it should give you an idea of how to do things.

Also, using strcpy() all over the place in your program is going to get you into trouble. For example, say you have a pointer that you assigned a malloc'd sector of memory to, length of 10 bytes to hold a 9 byte name. You then go and copy a new name into that same memory area, but the name is 20 bytes long. Your compiler won't complain, but your program may or may not crash at some point. As you are using pointers, you need to work in a manner I have shown in my code below.