Search code examples
c++typesstructure

error: expected unqualified-id before '.' token


10  struct element
11  {
12      int listnum;
13      char *tablename;
14      char** headl;
15      float** tabledata;
16      struct element *next;
17  };
18
19  struct element *next = NULL;
20  struct element *start= NULL;
21
22  void add_element(char *tablenameadd, char **headladd, float **tableadd, int hcols, int trows, int tcols)
23  {
24      int a=1;
25
26      struct element *pointer;
27
28  element.headl = new char*[hcols];
29  element.tabledata = new float*[trows][tcols];
...

I get an error while debugging this in eclipse as a C++ project. The 2 error-codes I receive are both

expected unqualified-id before '.' token

for program lines 28 and 29

Is there anyone able to help?

I changed it from a C project to a C++ project yesterday.


Solution

  • the statement

    element.headl 
    

    is wrong because element is the name of the data type, and what you are trying to do in to manipulate the structure defined under the name pointer so you have to change that to:

    struct element *pointer;
    pointer->headl = new char*...