How to read "string" from command line argument in C? -


i've question passing in parameters via command line.

my main() looks like

int main(int argc, char **argv){   int b, d, n, flag;     char *init_d, tst_dir[100];    argv++;   init_d=*(argv++);   //printf(); <--------what have init_d can print later? 

if argv pointer array of pointers i'm assigning init_d point value being pointed pointer argv points to? (if makes sense)

i assume have value character array in order print out if don't know size of "string" passing in, not sure how achieve this. instance if run code './myprogram hello' compared './myprogram alongerinput'

you can print arguments without transferring them character arrays. null-terminated c strings , printf eats them breakfast:

for (i=0; i<argc; i++)   printf("%s\n", argv[i]);   

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -