hello please help me.
im trying to make this code more dynmic i mean that
the array is not constant, i want that the user can input
lets say cout << "how many movies did you seen";
cin >> arraysize;
truct movies_t {
string title;
int year;
} films [arraysize];
but that's impossible becouse the arraysize has no value
so it give's me compiler error.
this is the exemple from the tutorial on ths site
about arrays and structures
i tried to combine the structure with pointer with no result,
please help me.
// array of structures
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
#define N_MOVIES 3
struct movies_t {
string title;
int year;
} films [N_MOVIES];
In C++, array sizes can only be dynamic if the array is dynamically allocated (by the use of new). But you should use a std::vector for something like this (it keeps a dynamically allocated array under the covers but does the housekeeping for you).