Re: problems in saving to a text file

From: Herbert Rosenau (os2guy_at_pc-rosenau.de)
Date: 10/30/04

  • Next message: CBFalconer: "Re: derangement: coding review request"
    Date: Sat, 30 Oct 2004 19:10:12 +0000 (UTC)
    
    

    On Sat, 30 Oct 2004 15:48:15 UTC, "kimimaro"
    <little_cloudie@yahoo.com> wrote:

    > hi below is my save function that is used to placed data from the C program
    > to a text file for future usage.
    >
    > void save()
    > {
    >
    > FILE *save;
    > int i = 0;
    > save=fopen("employeerecord.txt", "a+");
    >
    > do
    > {
    > if(strcmp(record[i].ID, "")!=0)
    > {
    > if(i!=0)
    > fprintf(save, "\n");
    > fprintf(save, "%s %s %s %s %s ", record[i].ID, record[i].Name,
    > record[i].Name2, record[i].Department[storage], record[i].Post[rank]);

    What tries you to do here? Write all records - except the first one -
    who have an epmty ID string?

    Seems to be a bad logic.

    Rething about you concept.
     
    > }
    > else
    > {
    > break;
    > }
    > i++;
    > }while(i<500);
    > fclose(save);
    > }
    >
    > There was no problem for me to save the first employee and the second but
    > when adding the 3rd employee data, this is what appears in the text file
    > :
    >
    > 1121 sonia cooling Management Maid 1121 sonia cooling Management Maid
    > 1331 mustapha jamal Management Office_Boy 1121 sonia cooling Management
    > Maid
    > 1121 sonia cooling Management Maid
    > 1331 mustapha jamal Management Office_Boy
    > 1111 cheng kahhin Administration Chief_Executive_Officer
    >
    > Sonia is the 1st employee I add, mustapha second and cheng the third. My
    > data are ID firstname secondname department post and it seems the 1st and
    > second loops before going to the third pls help if the problem is in the
    > save function if not its in the add_function but I want to make sure if
    > its the save function
    >
    This looks to be a bad design of your record structure. Something in
    memory gets overwritten and as result the whole data structure gets
    defektive even on disk.

    Restart your design from scratch to fix all the bugs.

    -- 
    Tschau/Bye
    Herbert
    Visit http://www.ecomstation.de the home of german eComStation
    

  • Next message: CBFalconer: "Re: derangement: coding review request"

    Relevant Pages

    • RE: Capturing an employee in a team at a point in time
      ... you will have a robust design that will not need altering. ... Access Query Grid interrogates the Windows setting and as ... you have entered a date in US m/d/y format. ... I would like to design a db that captures employee data. ...
      (microsoft.public.access.tablesdbdesign)
    • Re: Looking for PCB layout designer
      ... at a $5 adder to go to six layer), but that does *not* mean that they ... Descrimination against smart people (as well as ... for a digital design type job one question ... Are you saying that every employee should have identical skills? ...
      (sci.electronics.design)
    • Re: Still New to Access DB
      ... The tab order in the design view on the subform only is correct, ... Employee, can you add more than 1 record to it. ... EmpID ...
      (microsoft.public.access.tablesdbdesign)
    • Re: Design Pattern Question
      ... but Proxy is pretty much designed for restricted or selective access. ... interfaces for Employee that only provide X, X+Y, or Z access. ... one "hard-wires" the appropriate interface for each client. ... I would like to explore this design further. ...
      (comp.object)
    • Re: Need a design suggestion
      ... You're right about getting to the data design early, ... Google the access newsgroups for "books" ... > * How do I make the form go to the latest pay period upon opening it? ... > employee, percent worked and OT. ...
      (microsoft.public.access.tablesdbdesign)