hi
how do I put words into a specified location of a 2d array using scanf?
string movies[100][6]={};
in main
i need at least 100 rows and 5 columns
i want the user to enter the movie id, name
year, type and availability
it will be stored in a 2d array
i want to list what I've entered after words
it compiles but freezes when i try to list..
and if i hard coded the data it will list with no problems
i don't have any experience in strings..please help
here is my code..the part of adding a movie:
void Add_Movie(string movies[100][6]){
int answer;
int i;
for(i=0;i<100;i++){
printf("Movie ID:");
scanf("%s", &movies[i][0]);
printf("Movie Title:");
scanf("%s", &movies[i][1]);
printf("Movie Year:");
scanf("%s", &movies[i][2]);
printf("Movie Type:");
scanf("%s", &movies[i][3]);
printf("Availability:");
scanf("%s", &movies[i][4]);
printf("\n Do you want to add another movie? if no, enter 0");
scanf("%i",&answer);
if(answer == 0)
break;
}
List_Movie(movies);
}
here is the listing part:
void List_Movie(string movies[100][6]){
int i,j=1;
printf(" \n 4.List Movies\n");
printf("\n # Movie ID\t Title\t Year\t Type\t Available\n");
printf(" --------------------------------------------------------------\n");
for(i=0;i<10;i++){
if (movies[i][0]==NULL)
break;
if (movies[i][4]!="no"){
printf("%7i %6s %17s %6s %9s %9s\n", j , movies[i][0], movies[i][1], movies[i][2], movies[i][3], movies[i][4] );
j++;
}
}
}
what am i doing wrong??