How to receive a arg from command line in C -


I want to write a program to get an argument from the command line. It's like a type of etf ().

My program goes there:

  9 chars [] = "3.1415e-4"; 10 if (argc == 1) {11 print ("% e \ n", etf (s)); 12} 13 and if (RgC == 2) {14 / / strakpy (S, AGRV [1]); 15 printf ("% e \ n", etf (RGR [1])); 16}  

1. Would I just use argv [1] for the string to pass my ATF (), or will I put it in s []?

2. If I put it in better [], then is there some function to do "work"? Maybe some function strakpi () ??

Thank you.

I personally do this:

  #include & lt ; Stdlib.h & gt; # Include & lt; Stdio.h & gt; Int main (int argc, char ** argv) {const char defaultStr [] = "3.1415e-4"; Const char * arg = null; If (argc & lt; = 1) {arg = defaultStr; } Else {arg = argv [1]; } Printf ("% e \ n", etf); Return 0; }  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -