473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

the edit function

DanielTNBaker
my code adds people it deletes people it can even search for people but can it edit people......nope!

well this is what i got so far:
Expand|Select|Wrap|Line Numbers
  1. {
  2.    char name_val[30];
  3.    struct client_struct client_rec;
  4.    FILE * client_file;
  5.    clrscr();
  6.  
  7.    gotoxy(10,5);
  8.    textcolor(1);
  9.    cprintf("-------------------------------------------------");
  10.    gotoxy(10,7);
  11.    textcolor(15);
  12.    cprintf("Edit a Client");
  13.    gotoxy(10,9);
  14.    textcolor(1);
  15.    cprintf("-------------------------------------------------");
  16.    gotoxy(10,23);
  17.    textcolor(1);
  18.    cprintf("-------------------------------------------------");
  19.    gotoxy(10,13);
  20.    textcolor(15);
  21.    cprintf("Enter the Name of the Client Your Editing: ");
  22.    gotoxy(50,15);
  23.    gets(name_val);
  24.    client_file = fopen(CLIENTS, "rb+"); /*open .dat file*/
  25.  
  26.    clrscr();
  27.  
  28.    gotoxy(10,5);
  29.    textcolor(1);
  30.    cprintf("-------------------------------------------------");
  31.    gotoxy(10,7);
  32.    textcolor(15);
  33.    cprintf("Edit the Clients Details");
  34.    gotoxy(10,9);
  35.    textcolor(1);
  36.    cprintf("-------------------------------------------------");
  37.    gotoxy(10,37);
  38.    textcolor(1);
  39.    cprintf("-------------------------------------------------");
  40.    gotoxy(10,9);
  41.    textcolor(15);
  42.  
  43.    while(fread(&client_rec, sizeof(client_rec), 1, client_file))
  44.    {
  45.       if(strcmp(name_val,client_rec.name)==0)
  46.       {
  47.      printf("\n\n\n\t\tPlease Enter the Name of the Client: ");
  48.      fflush(stdin);
  49.      gets(client_rec.name);
  50.      printf("\n\t\tPlease Enter the Treatment for the Client: ");
  51.      printf("\n\t\tF = Full Body Massage,");
  52.      printf("\n\t\tB = Back Massage,");
  53.      printf("\n\t\tM = Manicure,");
  54.      printf("\n\t\tP = Pedicure,");
  55.      printf("\n\t\tD = Pamper Day: ");
  56.      client_rec.treatment = getche();
  57.      printf("\n\n\t\tPlease Enter the Time of the Appointment: ");
  58.      scanf("%f", &client_rec.time);
  59.      printf("\n\n\t\tPlease Enter the Day (1 = Monday, 2 = Tuesday etc): ");
  60.      scanf("%d", &client_rec.day);
  61.      printf("\n\n\t\tPlease Enter a Contact Number for the Client: ");
  62.      scanf("%f", &client_rec.contact);
  63.       }
  64.    }
  65.    textcolor(15);
  66.    fclose(client_file);
  67.  
  68.    getch();
  69.  
  70. }
  71.  
ive been told that i should use a do while loop

anyone got any ideas for this?
Mar 1 '07 #1
1 2017
sicarie
4,677 Expert Mod 4TB
my code adds people it deletes people it can even search for people but can it edit people......nope!

well this is what i got so far:
Expand|Select|Wrap|Line Numbers
  1. {
  2.    char name_val[30];
  3.    struct client_struct client_rec;
  4.    FILE * client_file;
  5.    clrscr();
  6.  
  7.    gotoxy(10,5);
  8.    textcolor(1);
  9.    cprintf("-------------------------------------------------");
  10.    gotoxy(10,7);
  11.    textcolor(15);
  12.    cprintf("Edit a Client");
  13.    gotoxy(10,9);
  14.    textcolor(1);
  15.    cprintf("-------------------------------------------------");
  16.    gotoxy(10,23);
  17.    textcolor(1);
  18.    cprintf("-------------------------------------------------");
  19.    gotoxy(10,13);
  20.    textcolor(15);
  21.    cprintf("Enter the Name of the Client Your Editing: ");
  22.    gotoxy(50,15);
  23.    gets(name_val);
  24.    client_file = fopen(CLIENTS, "rb+"); /*open .dat file*/
  25.  
  26.    clrscr();
  27.  
  28.    gotoxy(10,5);
  29.    textcolor(1);
  30.    cprintf("-------------------------------------------------");
  31.    gotoxy(10,7);
  32.    textcolor(15);
  33.    cprintf("Edit the Clients Details");
  34.    gotoxy(10,9);
  35.    textcolor(1);
  36.    cprintf("-------------------------------------------------");
  37.    gotoxy(10,37);
  38.    textcolor(1);
  39.    cprintf("-------------------------------------------------");
  40.    gotoxy(10,9);
  41.    textcolor(15);
  42.  
  43.    while(fread(&client_rec, sizeof(client_rec), 1, client_file))
  44.    {
  45.       if(strcmp(name_val,client_rec.name)==0)
  46.       {
  47.      printf("\n\n\n\t\tPlease Enter the Name of the Client: ");
  48.      fflush(stdin);
  49.      gets(client_rec.name);
  50.      printf("\n\t\tPlease Enter the Treatment for the Client: ");
  51.      printf("\n\t\tF = Full Body Massage,");
  52.      printf("\n\t\tB = Back Massage,");
  53.      printf("\n\t\tM = Manicure,");
  54.      printf("\n\t\tP = Pedicure,");
  55.      printf("\n\t\tD = Pamper Day: ");
  56.      client_rec.treatment = getche();
  57.      printf("\n\n\t\tPlease Enter the Time of the Appointment: ");
  58.      scanf("%f", &client_rec.time);
  59.      printf("\n\n\t\tPlease Enter the Day (1 = Monday, 2 = Tuesday etc): ");
  60.      scanf("%d", &client_rec.day);
  61.      printf("\n\n\t\tPlease Enter a Contact Number for the Client: ");
  62.      scanf("%f", &client_rec.contact);
  63.       }
  64.    }
  65.    textcolor(15);
  66.    fclose(client_file);
  67.  
  68.    getch();
  69.  
  70. }
  71.  
ive been told that i should use a do while loop

anyone got any ideas for this?
I would agree with using a while loop, I would also suggest getting rid of getch() , but that's a personal issue - several compilers are ok with it...
Mar 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Gilles T. | last post by:
How I can get element ID in the edit mode of datagrid control? If I not in the edit mode, there are no problem. <asp:TemplateColumn ItemStyle-CssClass="grid_column_width_3"...
4
by: Javier Gomez | last post by:
I have a query field which is a non editable field because is a function's result. Due to I need to edit the information, Can you please suggest me any solution for this problem?? (No matter...
7
by: ritchie | last post by:
Hi, I am writing for some help with editing a linked list. I would be gratful if anybody has the time to take a look at this. I am trying to edit a node by entering a date as a key. If an...
4
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml...
3
by: Schultz | last post by:
is there an easy to follow, source code in one document, article that explains how to create an edit all DataGrid control? and, I have a DataGrid setup where the client enters information for...
1
by: nate axtell | last post by:
In VB .Net I made a custom CheckBox column style (for the Datagrid control) that maps to two DataTable columns , one it uses for the Checked status and the other it uses for the Enabled status. I am...
1
by: pradeeba31 | last post by:
i was given a task in which i have to do the ui part using MFC. im having three editboxes. i used setfocus function for these edit(text boxes). when the user focus this text box it should do some...
1
by: Kosmös Pollard | last post by:
Hey guys, I'm rather new to access and can not seem to figure out what is wrong with this code I will post below...but first...it was working perfectly fine before I added this: recSet2.Edit...
1
by: Benny Ng | last post by:
Dear All, Now I met one problem in the development of my one application. I have one ASP.NET page. It's for disply the information of customer. But now I have one new requirement. It's to...
2
by: tristanlbailey | last post by:
I been scouring the Internet for an answer to my problem, and a couple of times thought I had almost found the answer, but still to no avail. I'm tying to use the Rich Edit class (riched20.dll),...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.