Not assignment rquest..having doof algorithms

H

happy

That request of having sorting program for that setup programs was not
a request to an assignment but to have good ideas about sorting record
..
#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);


}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top