Thread: Weird loop keep happeneing....pls help debug...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Diamonddrago's Avatar
    Join Date
    Nov 2009
    Posts
    6

    Weird loop keep happeneing....pls help debug...

    I wrote this program for a project due on the 21st.....

    well as it goes into a module SerEmp() it strats to do a weird lopping sequence...

    if u go thru option 1 > 4 u can search a record off a file that is opened....and i had included an error msg to catch any items that are not found.....and for some weird reason after the error message shows up....u cannot exit the program etc...it keeps flashing the error message even out of the module....

    everything has to stay void as i need to add more to the porgram...but for now...pls

    find out why its going out of wack.....i never seen such a logical error...ever....T.T


    void SerEmp(void)
    { clrscr();

    int Target,EmpID,Found;
    char check,EmpName[40],DOA[9],DOP[9],DOB[9],Mstat;
    FILE *mem,*pay;

    if((mem=fopen("E:\\Proj\\Member.dat","r"))==NULL)
    { printf("File is Empty!");
    sleep(2);
    SerEmp();
    }

    else
    { printf("Please Enter Employee ID to Search : ");
    fflush(stdin);
    scanf("%i",&Target);

    while (!feof(mem))
    { fscanf(mem,"%i %[^/]%*c %[^/]%*c %[^/]%*c %[^/]%*c %c",&EmpID,EmpName,DOA,DOP,DOB,&Mstat);
    if(Target==EmpID)
    { printf("Employee ID : %04i\n",EmpID);
    printf("Employee Name : %s\n",EmpName);
    printf("Date of Appointment : %s\n",DOA);
    printf("Date of Probational Period : %s\n",DOP);
    printf("Date of Birth : %s\n",DOB);
    printf("Maritial Status : %s\n",&Mstat);
    sleep(5);
    Employeemgt();
    }

    else if(Target!=EmpID)
    { printf("Record Not Found, please check Employee Id"); // Here is where it occurs......i can't find what i did wrng....pls help....
    sleep(2);
    Employeemgt();
    }
    }
    }

    //getch();
    fclose(mem);
    //Employeemgt();

    }
    Last edited by Diamonddrago; 11-19-2009 at 12:03 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. when a while loop will stop ?
    By blue_gene in forum C Programming
    Replies: 13
    Last Post: 04-20-2004, 03:45 PM
  2. How to change recursive loop to non recursive loop
    By ooosawaddee3 in forum C Programming
    Replies: 1
    Last Post: 06-24-2002, 08:15 AM
  3. for loop or while loop
    By slamit93 in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2002, 04:13 AM
  4. Replies: 1
    Last Post: 11-19-2001, 04:45 PM
  5. for loop = weird
    By -KEN- in forum C# Programming
    Replies: 2
    Last Post: 11-11-2001, 10:58 AM