void UpdateStudents(Student students[])
{
int choice;
for (int i=0;i<10;i++)
{
printf("What do you want to change?\n");
printf("1. Change ID number\n 2. Change Last Name\n 3. Change First Name\n 4. Change Date of Birth\n 5. Change Address\n 6. Change Telephone number\n 7. Change Program\n");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Input new ID number: ");
scanf("%d", &students[i].ID);
break;
case 2:
printf("Input new Last Name: ");
scanf("%d", &students[i].LastName);
break;
case 3:
printf("Input new First Name: ");
scanf("%d", &students[i].FirstName);
break;
case 4:
printf("Input new Date of Birth: ");
scanf("%d", &students[i].DateOfBirth);
break;
case 5:
printf("Input new Address: ");
scanf("%d", &students[i].Address);
break;
case 6:
printf("Input new Telephone Number: ");
scanf("%d", &students[i].TelephoneNumber);
break;
case 7:
printf("Input new Program: ");
scanf("%d", &students[i].ProgramPursued);
break;
default:
printf("Bad input\n");
break;
}
} }
- Codecall
- → Viewing Profile: Posts: Bouki
Check out our Community Blogs
Community Stats
- Group Just Joined
- Active Posts 20
- Profile Views 1689
- Member Title CC Newcomer
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
0
Neutral
User Tools
Friends
Bouki hasn't added any friends yet.
Posts I've Made
In Topic: Reading And Writing Files In C
09 April 2010 - 10:20 PM
How can i write what the user change back to the file "record.txt"
In Topic: Reading And Writing Files In C
09 April 2010 - 10:13 PM
What do u think abt this code
void UpdateStudents(Student students[])
{
char name[10];
int position;
int change;
printf("Enter the First name of the person record you want to edit: ");
scanf("%d", &name);
for (int i=0;i<10;i++)
{
if (strcmp(name,students[i].FirstName) == 0)
{
printf("Enter Index position of desired changes[0-6]:");
scanf("%d", &position);
printf("What do you want to change it to:");
switch(position)
{
case 0: scanf("%d",change_int);
student[i].id = change_int;
break;
case 1: scanf("%s",change_str);
strcpy(student.LastName,change_str);
break;
case 2: scanf("%s",change_str);
strcpy(student.FirstName,change_str);
break;
case 3: scanf("%d",change_int);
student[i].DateOfBirth = change_int;
break;
default: break;
}
}
In Topic: Reading And Writing Files In C
09 April 2010 - 09:49 PM
Thank you very much..I am gonna finish up and post it
In Topic: Reading And Writing Files In C
09 April 2010 - 09:22 PM
What im trying to do is allow the user to change anything he wants from the record. Updating it if he wants to change a name, id number, dob etc...
In Topic: Reading And Writing Files In C
09 April 2010 - 08:46 PM
I tried this function but not gettin what i want. Could u say step by step what i need to do plz
void UpdateStudents(Student students[])
{
char name[10];
int position;
int change;
printf("Enter the First name of the person record you want to edit: ");
scanf("%d", &name);
for (int i=0;i<10;i++)
{
if (name==students[i].FirstName)
{
printf("Enter Index position of desired changes[0-6]:");
fflush(stdin);
scanf("%d", &position);
printf("What do you want to change it to:");
fflush(stdin);
scanf("%d", &change);
Student students[position]=change;
}
}
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download
- Codecall
- → Viewing Profile: Posts: Bouki
- Privacy Policy
- Guidelines ·