Home > Back-end >  How to define a global variable by means of the initial load data
How to define a global variable by means of the initial load data

Time:03-06

Now I define
# define ROWS 20
The int data (ROWS);

Now hope that the value of the ROWS when I was in the program initialization through database load value, this can be achieved, or have any good way to achieve similar functionality?

CodePudding user response:

Create a database object
Establish a database connection with database objects
Create a recordset object
Performs a select statement on the recordset object to extract the numeric value corresponding to field of 20 rows of 20 is stored in the data array
Destroy the recordset object
Disconnect from the database
Destruction of database objects

CodePudding user response:

The
refer to the original poster xyj8035 response:
now I define
# define ROWS 20
The int data (ROWS);

Now hope that the value of the ROWS when I was in the program initialization through database load value, this can be achieved, or have any good way to achieve similar functionality?

You can, and specify the database through the terminal input array length makes no difference,

But, it is recommended that the original poster to define an array of zero growth degree, is to define a pointer, and then to the value read from the database after determined by means of dynamic application space memory;

Dynamic application malloc/free space, new/delete

CodePudding user response:

That is dynamically created int * pnArray=new int [XXXX];
  • Related