Not assignment request..having good algorithms

Discussion in 'C Programming' started by happy, Jan 14, 2005.

  1. happy

    happy Guest

    That request of having sorting program for such setup programs was not
    a request to an assignment but to have good ideas about sorting program
    ..
    #include <stdio.h>
    #include <conio.h>
    struct customer_record /*Defining a csutomer record*/
    {
    int customer_no;
    int no_of_weeks;
    char tv_type;
    };


    main ()
    {
    /*-------1-open file for output*/
    struct customer_record customer;
    FILE *fp_setup;
    if ((fp_setup=fopen("setup.txt","w")) == NULL)
    {
    printf("\nCan not open file 'setup.txt' for writing \n");
    printf("Program is termainted");
    exit();

    }


    clrscr();

    /*-------2-while more customers----------separate function-------*/
    do {
    /*-------2-1-input customers record------separate function-------*/
    customer_input(&customer);
    /*-------2-2-write customer record to file*/
    fprintf(fp_setup,"%4d%2d%c\n",customer);


    } while (another_customer()=='y');


    /*-------3-write end of file record to file */
    fprintf(fp_setup,"%4d%2d%c\n",9999,99,' ');
    /*-------4-close file*/
    fclose(fp_setup);
    return 0;


    }


    customer_input(cust)
    /*---------------------*/
    struct customer_record *cust;
    {
    printf("\nEnter customer number :");
    scanf("%4d",&(*cust).customer_no);
    printf("\nEnter number of weeks rent due :");
    scanf("%2d",&(*cust).no_of_weeks);
    printf("Enter type of rental -c for colors TV");
    printf("\n -b for black and white TV");
    printf("\n -v for video");
    printf("\n -o for other : ");
    scanf("\n");
    scanf("%c",&(*cust).tv_type);


    }


    another_customer()
    /*----------------*/
    {
    char another;
    printf("\nAnother new_screen_customer for input (y or n) : ");
    scanf("\n");
    scanf("%c",&another);
    return (another);


    }
     
    happy, Jan 14, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Birtle
    Replies:
    2
    Views:
    2,055
    John Saunders
    Oct 16, 2003
  2. Oplec
    Replies:
    0
    Views:
    387
    Oplec
    Oct 23, 2003
  3. happy
    Replies:
    0
    Views:
    235
    happy
    Jan 14, 2005
  4. vlsidesign
    Replies:
    26
    Views:
    988
    Keith Thompson
    Jan 2, 2007
  5. CellDivider
    Replies:
    11
    Views:
    664
    Jerry Coffin
    May 28, 2007
Loading...

Share This Page