473,666 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Declaring global variables

6 New Member
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 2754
gpraghuram
1,275 Recognized Expert Top Contributor
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 Recognized Expert Contributor
An array of lists would be a list<int>[], or for easier use, a vector<list<int >.
Jan 16 '08 #3
gpraghuram
1,275 Recognized Expert Top Contributor
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
53976
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 = '2005-01-01'
1
2423
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 program which control to requery. This makes it easy to requery controls on a different form. However, up until today, I was dimming a new local variable for each control I wanted to deal with ( E.G. Dim cbxctl as control) and then setting that...
4
6295
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
2592
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
2257
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() on WebForm1.aspx, I use "Public Property" and I declare variable _oRpte as Friend Shared. That's my problem. If I don't declare _oRpte as Friend Shared, I can't use WebForm1.oRpte() on other webpage. If I declare _oRpte as Friend Shared, I can use...
2
3767
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. Option Compare Database Global theDate As String Function DetermineDate() thedate = InputBox("Enter Volume Date YYYYMM")
2
2056
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 projects. For example, web page Page1 in Project1 will redirect to web page Page2 in Project2 which will further redirect to Page3 in project3 and Page4 in Project4 and finally back to Page1. In each web page, some session variables, such as...
8
7504
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, like this: for(var i=0; i<list; i++) { var name = list; }
2
1670
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 or the other when declaring a global variable? If not, what is (are) the major difference(s) ?
4
4350
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 of thta object, like this <script> function myobject(){} var a = new myobject();
0
8440
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8352
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7378
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.