Thread: i really need help asap

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    1

    i really need help asap

    can u help me debug this prog.

    zation);
    strSize=strlen(Specialization);
    do{
    if(isalpha(Specialization[idx])||isspace(Specialization[idx]))
    Valid=1;
    else
    Valid=0:
    ++idx;
    }while(Valid&&idx<strsize);
    if(!Valid)
    printf("Specialization Field Contains Invalid Characters");
    }
    length = strlen( (Specialization) );

    if (length > 30)
    {
    printf("Specialiazation Too Long - Please Try To Shorten \n");
    }
    }while (length > 30);
    }



    /****** Modify HR Staff Records ******/
    void mhr(FILE *name);
    {
    int ID;
    int length
    struct record ;

    /* open the file in update mode */
    if ((name = fopen("c:\\hr.dat", "rb+")) == NULL )
    {
    printf ("Error opening file: hr.dat");
    )
    printf("Please input the ID to modify => ");
    scanf("%i",&ID );

    fseek(name,(ID -1) *sizeof(struct rec),SEEK_SET);
    if (fread(&record,sizeof(struct rec), 1, name)!= 1)
    {
    printf (" error reading file in hr.dat \n");
    printf (" Press enter key to continue. \n");
    fflush(stdin);
    getchar();
    clrscr();
    }
    else
    { /***** check validity for employee_id *****/

    do
    {
    printf("Please Enter Employee ID => ");
    scanf("%i",&ID);

    if ( (ID < 1995001 ) || ( ID >2005099 ) )
    {
    printf ( "Sorry You Have Entered a Wrong ID,Try Again \n " );
    }
    }while ( ( ID < 1995001 ) || ( ID > 2005099 ));

    /***** Name & Validation *****/
    do{
    length=0;

    printf("Please Enter Employee name => ");
    scanf("%s",&name);
    fflush(stdin);
    gets(name);
    strSize=strlen(name);
    do{
    if(isalpha(name[idx])||isspace(name[idx]))
    Valid=1;
    else
    Valid=0:
    ++idx;
    }while(Valid&&idx<strsize);
    if(!Valid)
    printf("Name Field Contains Invalid Characters");
    }
    length = strlen( (name) );

    if (length > 40)
    {
    printf("Long Name - Please Try To Shorten \n");
    }
    }while (length > 40);

    /*****Age & Validation*****/
    do
    {
    length = 0;

    printf("Age => ");
    scanf("%i",&age);

    length= strlen( (age) );

    if(length > 2)
    {
    printf("Please Enter Logical Age");
    }
    }while (length > 2);

    /****** Gender & Validation ******/
    do
    {
    printf("Gender=>");
    scanf("%s",&Gender);
    if ( ( Gender!=M ) || ( Gender!=F ) )



    {
    printf ( "Invalid Gender,Please Enter M or F \n " );
    }
    }while ( ( Gender!=M) || (Gender!=F ));

    /****** Position & Validation ******/
    printf("Position => ");
    scanf("%s",&Position);
    fflush(stdin);
    gets(Position);
    strSize=strlen(Position);
    do{
    if(isalpha(Position[idx])||isspace(Position[idx]))
    Valid=1;
    else
    Valid=0:
    ++idx;
    }while(Valid&&idx<strsize);
    if(!Valid)
    printf("Position Field Contains Invalid Characters");
    }
    /****** Country Of Birth & Validation ******/
    do{
    length=0;

    printf("Country Of Birth => ");
    scanf("%s",&Country_of_birth);
    fflush(stdin);
    gets(Country_of_birth);
    strSize=strlen(Country_of_birth);
    do{
    if(isalpha(Country_of_birth[idx])||isspace(Country_of_birth[idx]))
    Valid=1;
    else
    Valid=0:
    ++idx;
    }while(Valid&&idx<strsize);
    if(!Valid)
    printf("Country Of Birth Field Contains Invalid Characters");
    }

    length = strlen( (Country_of_birth ) );

    if (length > 30)
    {
    printf("Country name too long - Please Try To Shorten \n");
    }
    }while (length > 30);
    }


    /****** Highest Qualification & Validation ******/

    do{
    length=0;

    printf("Highest Qualification => ");
    scanf("%s",&Highest_qualification);
    fflush(stdin);
    gets(Highest_qualification);
    strSize=strlen(Highest_qualification);
    do{
    if(isalpha(Highest_qualification[idx])||isspace(Highest_qualification[idx]))
    Valid=1;
    else
    Valid=0:
    ++idx;
    }while(Valid&&idx<strsize);
    if(!Valid)
    printf("Highest Qualification Field Contains Invalid Characters");
    }

    length = strlen( (Highest_qualification ) );

    if (length > 30)
    {
    printf("Qualification too long - Please Try To Shorten \n");
    }
    }while (length > 30);
    }

    /******Years of service******/

    do{
    length = 0;

    printf("Years Of Service => ");
    scanf("%i",&Years_of_service);

    length= strlen( (Years_of_service) );

    if(length > 2)
    {
    printf("Please Enter Logical Years Of Service");
    }
    }while (length > 2);
    }

    /******Specialization******/

    do{
    length=0;

    printf("Specializaton => ");
    scanf("%s",&Specialization);
    fflush(stdin);
    gets(Specialization);
    strSize=strlen(Specialization);
    do{
    if(isalpha(Specialization[idx])||isspace(Specialization[idx]))
    Valid=1;
    else
    Valid=0:
    ++idx;
    }while(Valid&&idx<strsize);
    if(!Valid)
    printf("Specialization Field Contains Invalid Characters");
    }
    length = strlen( (Specialization) );

    if (length > 30)
    {
    printf("Specialiazation Too Long - Please Try To Shorten \n");
    }
    }while (length > 30);
    }



    do
    {
    length = 0;
    fseek(name,(rec_no-1) *sizeof(struct rec),SEEK_SET);
    if (fwrite(&record,sizeof(struct rec), 1, name) != 1 )
    {
    printf (" error in writing file in maccounts.dat\n " );
    fflush(stdin);
    getchar();
    clrscr();
    }
    else
    {
    printf ("The file is successfully modified \n");
    printf (" Press enter key to continue. ");
    }
    }
    fflush (stdin);
    getchar();
    clrscr();

    fclose(name);
    return ;
    }
    /****** Delete HR Staff Records ******/
    void Dhr(FILE *name)
    {
    char name[40];
    int ID=0;
    int age;
    char Gender[1];
    char Position[30];
    char Country_of_birth[30];
    char Highest_qualification[30];
    int Years_of_service[2];
    char Specialiazation[30];
    FILE *sfile,*temp;
    temp=fopen("c:\\temp.dat","w");
    if((sfile=fopen("c:\\hr.dat","r"))==NULL)
    printf("File Empty!");
    else
    {
    printf("Enter Name To Delete:");
    fflush(stdin);
    gets(Target);
    while(!feof(sfile))
    {
    fscanf(sfile,"%i%c%i%c%c%c%c%i%c",&ID,&name,&age,& Gender,&Position,&Country_of_birth,&Highest_qualif ications,&Years_of_service,&Specialiazation);
    if(feof(sfile))
    break;
    if(strcmp(Target,name)!=0)
    fprintf(temp,"%i%c%i%c%c%c%c%i%c",&ID,&name,&age,& Gender,&Position,&Country_of_birth,&Highest_qualif ications,&Years_of_service,&Specialiazation);
    else
    {
    Found=1;
    printf("ID: %04i\n",ID);
    printf("Name: %s\n",name);
    if(toupper(Gender)=='f')
    printf("Gender: Female\n");
    else
    printf("Gender: Male\n");
    printf("Age =>%i/n",age)
    printf("Country of birth=>%s",Country_of_birth);
    printf("Highest qualifications=>%s",Highest_qualification);
    printf("Years of service=>%i,Years_of_service);
    printf("Specialization=>%s",Specialization);
    }
    }
    if(!Found)
    printf("Record not found!\n");
    fclose(sfile)
    fclose(temp)
    remove("c:\\hr.dat");
    rename("c:\\temp.dat","c:\\hr.dat");
    }

    /****** View HR Staff Files ******/
    void vhr(FILE *name);
    struct rec
    char name[40];
    int ID=0;
    int age;
    char Gender[1];
    char Position[30];
    char Country_of_birth[30];
    char Highest_qualification[30];
    int Years_of_service[2];
    char Specialiazation[30];
    FILE *sfile;

    if((sfile=fopen("c:\\hr.dat","a+"))==NULL)
    printf("File Empty!");
    else
    {
    while(!feof(sfile))
    {
    fscanf(sfile,"%i%c%i%c%c%c%c%i%c",&ID,&name,&age,& Gender,&Position,&Country_of_birth,&Highest_qualif ications,&Years_of_service,&Specialiazation);
    if(feof(sfile))
    break;
    printf("%i%c%i%c%c%c%c%i%c",&ID,&name,&age,&Gender ,&Position,&Country_of_birth,&Highest_qualificatio ns,&Years_of_service,&Specialiazation);
    }
    }
    printf("\nEnd of File,Press Any Key To Exit");
    fclose(sfile);
    }

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    88
    rrriiiight.........

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help ASAP ,
    By Haytham in forum C Programming
    Replies: 3
    Last Post: 05-14-2007, 10:21 AM
  2. Need Help ASAP....
    By Maxwell in forum C++ Programming
    Replies: 16
    Last Post: 09-14-2005, 06:56 PM
  3. Help Needed Please... Asap
    By Shabba in forum C Programming
    Replies: 2
    Last Post: 01-13-2004, 04:24 PM
  4. Count_nums (need help ASAP!)
    By legacye in forum C Programming
    Replies: 6
    Last Post: 11-22-2003, 06:32 PM
  5. Help Needed Asap With Searching An Array!
    By HelpMe++ in forum C++ Programming
    Replies: 5
    Last Post: 05-23-2003, 04:44 AM