How to get the Command line argument to read output from another method in the same c program files?

322 Views Asked by At
            /*Populate the int array mahRands with random numbers using a function which
        you then invoke from the main method.
        */
        #include <stdio.h>
        #include <stdlib.h>
        
        // use rand() % some_number to generate a random number
        void functionRan(){
            int i;
            int mahRands[3];
            for(i = 0;i < 3; i++){
                mahRands[i] = rand() % 200;
                printf("%d ",mahRands[i]);
                }
        }
        //command line argument
        int main(int argc, char *argv[])
        /*argc (argument count) and argv (argument vector)
        argc is the number of things `enter code here`in the command line 
        argv is an array that hold the char values that where entered*/
        {
            //functionRan();
            int i;
            for(i =0; i< argc; i++){
                printf("\nargv[%d] = %d",i,argv[i]);// argv[0] = 41;
            }
         return 0;
         
        }
 

My output is argv[0] = 6628720 I want main "the command line argument" to read functionRan and set the arraylength and its values to argc and argv".there should be 3 outputs. The numbers are generated random.
argv[0] = 66 argv[1] = 26 argv[2] = 87

0

There are 0 best solutions below