2 Replies - 571 Views - Last Post: 01 July 2008 - 07:47 AM Rate Topic: -----

#1 rajesh_strg  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 01-July 08

Struct in C++

Post icon  Posted 01 July 2008 - 01:37 AM

can u plz exlpain me about Structure (struct keyword) and it uses. And passing the pointers to array...
ex:
struct
{
   char *temp[500];
   int *cnt;
}table;



how to use char *temp[500];
can briefly explain about Structures.

** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: Struct in C++

#2 AmitTheInfinity  Icon User is offline

  • C Surfing ∞
  • member icon

Reputation: 117
  • View blog
  • Posts: 1,559
  • Joined: 25-January 07

Re: Struct in C++

Posted 01 July 2008 - 01:42 AM

View Postrajesh_strg, on 1 Jul, 2008 - 02:07 PM, said:

can u plz exlpain me about Structure (struct keyword) and it uses. And passing the pointers to array...
ex:
struct
{
   char *temp[500];
   int *cnt;
}table;



how to use char *temp[500];
can briefly explain about Structures.

** Edit ** :code:



You can go through various rich websites dedicated to C++ for that. for example see this one : http://www.cplusplus...structures.html

This will clear all doubts about it. Still if you are unclear about any of it, do post back here.
Was This Post Helpful? 0
  • +
  • -

#3 polymath  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 670
  • Joined: 04-April 08

Re: Struct in C++

Posted 01 July 2008 - 07:47 AM

You can always create a pointer to the structure and then modify it.

Example:
#include <iostream>

struct
{
   char *temp[500];
   int cnt;
}table;

int main() {
   table * EXAMPLE;
   cout << "How many arrays? ";
   cin >> table->cnt;
   table->temp=new char[cnt][500]
   cout << "Structure Table now contains a multidimensional array with "
      << cnt
      << " arrays and 500 elements in each array, for a total of "
      << (cnt * 500)
      << " total elements. \nPress any key to exit. ";
   system(pause>nul);
   return 0;
   delete[][] table->temp;
}



I think i made a few errors, working quickly. But you can get the basic idea.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1