I want to create an edit function that receives as a parameter by reference the vector of songs. (using pointers)
The user must choose the number of the song and re-enter the data of that position of the vector.
I created the struct, I'm already receiving the values and I'm playing. But I do not know how to edit the values. Anyone to help me start this part?
#include <stdio.h>
#include <stdlib.h> //
#include <stdbool.h>
#include <locale.h>
#include <string.h>
struct registry_of_music {
char name[50];
char artist[60];
char url[80];
};
struct registry_of_music music[9];
int main() {
int i;
printf("\nRegistry of Music\n\n\n");
for(i = 0; i <= 3;i++ ){
printf("Name of Music: ");
fflush(stdin);
fgets(music[i].name, 50, stdin);
printf("Name of Artist: ");
fflush(stdin);
fgets(music[i].artist, 60, stdin);
printf("URL of Internet: ");
fflush(stdin);
fgets(music[i].url, 80, stdin);
}
int op;
do
{
printf("1 - Play\n");
printf("2 - Edit\n");
printf("3 - Exit\n");
printf("Please enter a value:");
scanf("%d", &op);
switch(op) {
case 1: play();
break;
case 2: edit();
break;
case 3: printf("Bye\n");
break;
default: printf("Try Again\n");
}
} while (op!=3);
getch();
return(0);
}
void play(){
int i;
for(i = 0; i <= 3;i++ ){
printf("Name ...........: %s", music[i].name);
printf("Artist .....: %s", music[i].artist);
printf("URL .....: %s", music[i].url);
}
}
void edit(){}