Passing an int array through argv WAS: my own Very revised aueston 
Author Message
 Passing an int array through argv WAS: my own Very revised aueston

If I need to pass to main an int array as one of the paramters, what
format does the array need to take and how do I translate the char  
pointer in argv, say argv[2]?  Would it be in a loop, like
int i;
int keyArray[40];
for(i=9; i < 40; i++)
  keyArray[i] = argv[2][i];

Would the input array need to look like
23, 23, 45, 67, 34,
with commas and blanks between the numbers, or just blanks or what? I'm
sorry if this seems like a simple thing but I've got three C books on my
shelf, plus I've lloked at hte faq.  I don't need to do the table lookup
mentioned in the VERY revised question posting, but I do need to do
everuthing else in there.  If I knew how to erse a posting to a news
group, I'd erase it.  Thanks.

Ken Litwak

P.S.,

   SOrry if thee's ben confusionover the name of the sender.  We only
have one machine for Internet access right now, so we share.



Mon, 31 May 1999 03:00:00 GMT  
 Passing an int array through argv WAS: my own Very revised aueston

Quote:

> If I need to pass to main an int array as one of the paramters, what
> format does the array need to take and how do I translate the char  
> pointer in argv, say argv[2]?  Would it be in a loop, like
> int i;
> int keyArray[40];
> for(i=9; i < 40; i++)
>   keyArray[i] = argv[2][i];

Do something like ;

#include <stdio.h>
#include <stdlib.h>

int keyArray[40]

int main(int argc, char *argv[])
{
 int i;

 for(i = 1 ; i < argc ; i++)
     keyArray[i-1] = atoi(argv[i]);

 return 0;

Quote:
}

Cheers, flux.


Tue, 01 Jun 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. int main( int argc, char *argv[] )

2. how do I pass int array by reference?

3. passing of pointers to int arrays?

4. Passing struct to dll with int array

5. int main(int argc, char* argv[])-argc, argv are not used .

6. Passing int vs. passing char

7. main ( int argc, *char argv )

8. main(int argc, char **argv) legal?

9. Wondering about void main (int argc, char *argv[])

10. at main(int argc,cha *argv[])

11. Reversed char* argv[], int argc

12. Can't get int function ptr from argv

 

 
Powered by phpBB® Forum Software