473,378 Members | 1,680 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,378 software developers and data experts.

Help with command-line prog

Im writing a command-line program in unix. Whenever I run the prog in unix it gives me 49 output files instead of the user entered amount. Im not sure what the problem is with my main prog the loop looks fine
Expand|Select|Wrap|Line Numbers
  1.  
  2. int main(int argc, char * argv[])
  3. {
  4.     // Command Arguements
  5.  
  6.     // Usage: <program> <policy file> <gen file prefix> <num generations>
  7.     // argv[1] is the name of the policy file
  8.     // argv[2] is the string that the generation output file starts with 
  9.     // argv[3] the number of generations that will be evolved in this simulation
  10.  
  11.        if(argc != 4) {
  12.         cout << "Usage:\n   " << argv[0] << " <policy file> <gen file prefix> <num generations>" << endl;
  13.         return -1;
  14.     }
  15.  
  16.     Policy thePolicy(argv[1]);
  17.     Generation * gPtr[*(argv[3])];
  18.     gPtr[0]= new Generation(thePolicy, argv[2]);
  19.     for (int i=1; i<=(*(argv[3])); i++)
  20.           gPtr[i]= new Generation(thePolicy, gPtr[i-1], argv[2]);
  21.     return 0;
May 6 '07 #1
3 1487
weaknessforcats
9,208 Expert Mod 8TB
This code:
Expand|Select|Wrap|Line Numbers
  1. Generation * gPtr[*(argv[3])];
  2.  
Isn't argv[3] a char*? As in a C string?

If the argv[3] string is 10, then argv[3] is the address of the 1. Therefore,
*argv[3] will be the character 1, which has an integer vaue of 49.
May 7 '07 #2
This code:
Expand|Select|Wrap|Line Numbers
  1. Generation * gPtr[*(argv[3])];
  2.  
Isn't argv[3] a char*? As in a C string?

If the argv[3] string is 10, then argv[3] is the address of the 1. Therefore,
*argv[3] will be the character 1, which has an integer vaue of 49.
So how would I go about making the number of generations be user defined?
May 7 '07 #3
This code:
Expand|Select|Wrap|Line Numbers
  1. Generation * gPtr[*(argv[3])];
  2.  
Isn't argv[3] a char*? As in a C string?

If the argv[3] string is 10, then argv[3] is the address of the 1. Therefore,
*argv[3] will be the character 1, which has an integer vaue of 49.
Yea thanx I got it I just have to use atoi(argv[3]). I didnt realize that it was a character*.
May 7 '07 #4

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

Similar topics

3
by: aToaster | last post by:
Hey guys, I'm just getting the hang of Python and Tkinter and I could use some help. I wrote most of the gui for my calculator program, well I haven't gotten around to putting in the...
1
by: Naren | last post by:
Victor Bazarov <v.Abazarov@comAcast.net> wrote: >Naren wrote: >> MyServer class conatins a list of Mysock class. >> >> class Myserver >> { >> private: >> list<Mysock> L1; >> }; >>
4
by: Madhu Gopinathan | last post by:
Hi All, I am faced with a horrible hang problem. I have a COM exe server that executes some tasks. The task execution manager is a thread that manages the pool of threads, which is 4 per processor....
3
by: Merdelus | last post by:
I'm a new visual basic learner, I need some help with this program below: create an application that either sums or averagethe rows or columns of a two dimensional array depending on user...
2
by: Merdelus | last post by:
I'm a new visual basic learner, I need some help with this program below: create an application that either sums or averagethe rows or columns of a two dimensional array depending on user...
0
by: Edwinah63 | last post by:
Hi guys, i am not new to vb6, but a mere tyro in vb.net what i want to do is the following open transaction build an ADODB command object using parameters execute it build another command...
5
by: rover8898 | last post by:
Hello all, I have a programming problem/challenge. Let explain my scenario: I have a C program (distributed accross many files and functions) that is responsible for handling hardware. This...
7
by: The Man | last post by:
Hello All: I am in desparate need of assistance. We are using an application called PaperVision Enterprise which takes scanned invoices and puts them into a database for the purpose of easy...
4
by: Guern1 | last post by:
Hi Need a bit of help here please to point me in the right direction. I have a java class file here which i wish from a menu item to open a web page which contains a help page. ] } else...
9
by: Chris Ahmsi | last post by:
I have been tasked to create a 'simple' form in Access providing managers to input necessary changes. I have 2 command buttons on the form and a check box. Command button 1 updates my table for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.