473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Declaring global variables

6
hi, essentially, my program needs to store an array of lists so that in main() it can have 2 run modes from the command line.

i.e. i can run the program with
Expand|Select|Wrap|Line Numbers
  1. ./matrix load filename
to load a matrix into my array of lists
then use
Expand|Select|Wrap|Line Numbers
  1. ./matrix find 1 3
to do something to the matrix I have just made (which is an array of lists)

i was going to create a global variable which was an array of lists but i need to know the size of it to declare it that way and I only know the size by running ./matrix load filename

Any ideas on how to go about this or other ways around it?

Cheers, Dan

P.S Dont ask why I am using an array of lists (but its pretty important that i do it that way)
Jan 16 '08 #1
3 2740
gpraghuram
1,275 Expert 1GB
hi, essentially, my program needs to store an array of lists so that in main() it can have 2 run modes from the command line.

i.e. i can run the program with
Expand|Select|Wrap|Line Numbers
  1. ./matrix load filename
to load a matrix into my array of lists
then use
Expand|Select|Wrap|Line Numbers
  1. ./matrix find 1 3
to do something to the matrix I have just made (which is an array of lists)

i was going to create a global variable which was an array of lists but i need to know the size of it to declare it that way and I only know the size by running ./matrix load filename

Any ideas on how to go about this or other ways around it?

Cheers, Dan

P.S Dont ask why I am using an array of lists (but its pretty important that i do it that way)

Hi,
i assume that you are asking the way how to declare the list array.
Expand|Select|Wrap|Line Numbers
  1. typedef list<int> Int_List;
  2. Int_List *list_arr;
  3.  
The above piece helps you to acjieve the same

Thanks
Raghuram
Jan 16 '08 #2
Laharl
849 Expert 512MB
An array of lists would be a list<int>[], or for easier use, a vector<list<int>.
Jan 16 '08 #3
gpraghuram
1,275 Expert 1GB
An array of lists would be a list<int>[], or for easier use, a vector<list<int>.

What you say is right.
Since he has tole that he has to use array and the sie will be determined at run-time i went for this approach

Raghuram
Jan 16 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ross.oneill | last post by:
Hi, I am having trouble with a simple task of declaring a variable. Is this possible? Here is what I want to do. DECLARE start_date date; DECLARE end_date date; SET start_date =...
1
by: ColinWard | last post by:
Hi guys. I have a question about declaring variables. I do a lot of re-querying of controls in my database and I use the Set statement with a variable set to the name of the control to tell the...
4
by: Lucy | last post by:
In the Declarations section of a form's code module, what is the difference between the following: Dim Flag As Boolean Public Flag As Boolean Private Flag As Boolean Thanks!
10
by: athanasios.silis | last post by:
Hello everyone, i am attempting to make a structure #include "globalVars.h" struct myStruct{ int offset; unsigned char uChars; } saveVars, getVars;
3
by: jbeteta | last post by:
Hello, I have a problem declaring variables. I need to create an object oRpte as ReportClass on WebForm1.aspx and be able to use its value on WebForm2.aspx. For declaring the property oRpte()...
2
by: majel | last post by:
I just read an older post that described declaring global variables. I tried this but I'm getting an error and the text stays red. What am I doing wrong? This code is behind a form. Thanks. ...
2
by: TARUN | last post by:
I have a question about declaring the Global.ascx: In VS.NET I create a Solution, and there are 4 projects under it. They are put under 4 folders, but web pages would be called across the 4...
8
by: SM | last post by:
I've always wonder if there is diference when declaring and initializing a varible inside/outside a loop. What's a better practice? Declaring and initializing variables inside a loop routine,...
2
by: MLH | last post by:
I'm wondering about Public VS Global kewords that can be used in procedures inside global modules saved/viewd in the modules tab of the database window. Is it pretty much the same thing to use one...
4
by: Sister Ray | last post by:
I've searched for a way to this in a lot of forums. Haven't found a solution for this, however I've found a work around. Declaring a public object and then adding the variables i want as members...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.