Hello there,
I’m having problem with argc and argv.
The program suppose to work in such a way that once an input from the argc it will display the srand num.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[])
{
int i;
printf("%d\n", argc);
for(i=0; i<argv; i++)
if(argc > 1)
{
int num;
srand(time(NULL));
while(num-- > 0)
printf("%d ", rand() % 10);
}
return(0);
}
The code above, doesn't seems to be right. Which I'm aware but having trouble understanding and combining different functions and arguements as a whole. As for now, I do understand how it works individually.
Code:
#include <stdio.h>
int main(int arc, char *argv[])
{
int i;
printf("%i\n", argc);
for(i=0; i< argc; i++)
printf("%s\n", argv[i]);
return(0);
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main (void)
{
int num=10;
srand(time(NULL));
while(num-- > 0)
printf("%d ", rand() % 10);
return(0);
}
Really appreciate any help.
Thanks in advance!