Im kinda new to programming, so my question is a simple one. I have came across term of data structures, and have been toying with some basic exsamples of them. While

int *pointer [10];
struct cell{
  int death;
};
int main ()
{
  cell test;
  cell * pointer[0];
  pointer[0] = &test;
  pointer[0] -> death = 5;
  cout <<  pointer[0] -> death ;  
  cin.get();
  return 0;
}

Works perfectly fine, it shows an error whenever i try to get the "cout" part into a function

int *pointer [10];
struct cell{
  int death;
};  
int test() {cout <<  pointer[0] -> death;}
int main ()
{
  cell test;
  cell * pointer[0];
  pointer[0] = &test;
  pointer[0] -> death = 5;
  test()
  cin.get();
  return 0;
}

And I wonder why it happens, and how to pull it correctly.

Thank you for your help.

int *pointer [10];
struct cell{
  int death;
};  
int test() {cout <<  pointer[0] -> death;}
int main ()
{
  cell test;
  cell * pointer[0];
  pointer[0] = &test;
  pointer[0] -> death = 5;
  test()
  cin.get();
  return 0;
}

You've declared pointer twice.

Thank you for your answer, think it works now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.