helpmegenya
asked on
newbie needs help!!!!!
void modify_rec(my_rec_t arr[], int size){
int id;
int test=0;
int i;
char c;
char addr[40];
printf("Enter id of the record to be modified:\n");
scanf("%d%*c", &id);
for (i = 1; i < size+1; i++)
{
// next: compare names (hint: use a library function)
if (arr[i].id == id)
{
test = i+1;
if (test==0){
printf("Record does not exist.\n");
return size;
}
}
}
printf("Enter Address:\n");
fgets(addr, 40, stdin);
addr[strlen(addr)-1] = '\0';
printf("Enter Age:\n");
scanf("%d",&arr[test].age) ;
strcpy(arr[test].addr,addr );
right now, 2 cases...either the program will ask you for an address regardless of if there is a id that exists within arr[100] or it will continously say record does not exist
int id;
int test=0;
int i;
char c;
char addr[40];
printf("Enter id of the record to be modified:\n");
scanf("%d%*c", &id);
for (i = 1; i < size+1; i++)
{
// next: compare names (hint: use a library function)
if (arr[i].id == id)
{
test = i+1;
if (test==0){
printf("Record does not exist.\n");
return size;
}
}
}
printf("Enter Address:\n");
fgets(addr, 40, stdin);
addr[strlen(addr)-1] = '\0';
printf("Enter Age:\n");
scanf("%d",&arr[test].age)
strcpy(arr[test].addr,addr
right now, 2 cases...either the program will ask you for an address regardless of if there is a id that exists within arr[100] or it will continously say record does not exist
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please proceed with that recommendation.
My recommendation, which I will post in the Cleanup topic area, is to
split points between AlexFM [25 pts] and mayankeagle [50 pts].
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
jmcg
EE Cleanup Volunteer