Altering the Properties of Pointer Objects

Hello everyone, I'm new to this forum and C++

I'm writing a program that will let you create a faux database. Basically I want to use dynamic memory to let users create arrays of objects with properties they define.

I've run into an issue that I don't fully understand, though, so I thought I'd ask for a little help : )

I want to declare an object as a pointer (because later I'll make the object into a new array with a variable in its index), and let the user change the value of one of the properties. Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

#include <iostream>
#include <string>

using namespace std;

        struct props{
            char numval[10];
            char altval[10];
        };

    class DataObj{
        public:

            props * numprop;//this will become an array which contains properties that house number values

            char DataName[10];//the name of the data can't be longer than 10 letters//

            props * altprop;//this will become an array which contains the different properties.
    };

int main()
{

        cout << "Type in the name of the objects you want to collect data on(for example, \'Books\' or \'Cars\')\n\n\t";

        DataObj * Entry;

        cin >> (*Entry).DataName;

//the code goes on from here, but this is where the runtime error occurs.//


So is it just that you can't change the properties of a pointer? It compiles perfectly. It's just that a runtime error crashes it after the user changes the value of the DataName property.

Entry doesn't point to anything yet. Either allocate an object with new or assign an address of some object to it.
That worked! Thanks a lot : D
Topic archived. No new replies allowed.