Hi ppl... I need to make a program with struct that can add, modify, delete and search information in inside tha strut. My problem is keeping the information in a vector. Im posting the program half made... so dont mind the unused voids... I managed to show in screen at least one of the added information, but I cant get it to show the rest in void writeMovie. To make this I used Bloodshed DEV++
And sorry for the bad english (Im Brazilian)... plz help
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include <ctype.h>
#include <iostream>
#include <fstream>
typedef char string[51];
typedef struct {
string title, director, code, genre, year, available;
}MOVIE;
char inbuf;
void addMovie (MOVIE list[500]);
void readMovie (MOVIE list[500], int count);
void writeMovie(MOVIE list[500], int count);
void searchMovie(MOVIE list[500], int count);
int counting(int count);
//---------------------------------------------------------------
int main(){
MOVIE list[500];
int count=0;
readMovie(list, count);
writeMovie(list, count);
getch();
}
//---------------------------------------------------------------
void addMovie (MOVIE list[500]){
fflush(stdin);
puts("Movie Title:");
gets((*list).title);
puts("Movie's Director:");
gets((*list).director);
puts("Year of Making:");
gets((*list).year);
puts("Movie Code:");
gets((*list).code);
puts("Numerber of copies Available:");
gets((*list).available);
puts("Genre:(R)Romance, (F)Fiction, (A)Action, (C)Comedy:");
gets((*list).genre);
}
//---------------------------------------------------------------
void readMovie(MOVIE list[500], int count){
int i;
char option;
for(i=count; ; i++){
system("CLS");
addMovie(&list[i]);
counting(count);
puts ("Do you wish to add another movie?(Y)/(N)");
scanf("%c",&option);
if (option != 'Y' && option != 'y')
break;
}
}
//---------------------------------------------------------------
int counting(int count){
count=count+1;
return count;
}
//---------------------------------------------------------------
void searchMovie(MOVIE list[500], int count){
string search1, search2;
int i;
puts("Type in Movie's Name");
gets (search1);
for (i=0; i=count; i++)
if (search1 == list[i].title){
puts("Type the Movie's Genre (R)Romance, (F)Fiction, (A)Action, (C)Comedy");
scanf ("%c", search2);
if (search2 == list[i].genre){
printf("%s\t%c", list[i].director, list[i].code);
}
puts ("Movie does not exist in the list");
}
}
//---------------------------------------------------------------
void writeMovie(MOVIE list[500], int count){
int i;
puts("Complete Movie List:");
for(i=0; i=count; i++);
printf("%s\t%s\t%s\t%s\t%s\t%s\t", list[i].title, list[i].director,
list[i].code, list[i].genre, list[i].year, list[i].available);
}