How to receive a arg from command line in C
- by 115599yy
Hi everyone:
I want to write a program to receive a argument from command line. It's like a kind of atof().
There my program goes:
9 char s[] = "3.1415e-4";
10 if (argc == 1) {
11 printf("%e\n",atof(s));
12 }
13 else if (argc == 2) {
14 //strcpy(s, argv[1]);
15 printf("%e\n",atof(argv[1]));
16 }
1.should I just use argv[1] for the string to pass to my atof(), or, put it into s[]?
2.If I'd better put it in s[], is there some build-in function to do this "put" work? maybe some function like strcpy()??
thanks.