I was given an assignment to complete on database, i have created it and also works but crashes after executing once, check it friends and please help, if you can modify or make it works my time is really limited and am unable to find a solution, friends be graceful to share your knowledge.

Please find the coding in attachment section. thanks, hope will get good response

1. Do not use *.cpp files as includes in other *.cpp files. rename those two *.cpp files (functions_prototype.cpp and struct.cpp) to *.h.

2. Add <string> to functions_prototype.h. Many compilers, such as vc++ 2010 do not automatically include that header file.

3. Several times you have forgotten to add 1 to strlen(tName) when allocating new memory.

4. in saveToFile(), calculate the length of tName only once and use that calculation in the loop. Its bad practice to call strlen() in a loop when the length never changes because its too time consuming.

//add "+" to join name with spaces  
        size_t len = strlen(tName);     // <<<< AD
        for (size_t j=0; j<len-1; ++j)  // <<<< AD
        {
             if(tName[j] == ' ') tName[j] = '+';
        }

5. MenuOperation(), case '1'. Here is the correct way to clear the cin input buffer. Read this thread for more detailed information.

//cin.ignore(); // <<< AD
         //cin.ignore(0);
         //cin.clear();
         //cin.sync();
         cin.ignore ( std::numeric_limits<std::streamsize>::max(), cin.widen ( '\n' ) );

There are other errors that I have not tried to find. Fix the above and you will be able to do more than just the first record that you mentioned. I don't know what compiler you are using, but you need to learn how to use your compiler's debugger so that you can easily single-step through the program and set breakpoints. I found all the above problems in about 15 minutes doing that with vc++ 2010 express.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.