c - confusion while understanding parameters of main -


while understanding parameters of main function i.e, int argc, char* argv[]

i wrote piece of code understand these parameters.

#include <stdio.h> int main(int argc,char*argv[]) {     printf("test\n");     printf("%d %c",argc,*argv[argc-1]);     return 0; } 

this prints

test

1 f

here don't understand why there f output. mean how executed result in output f ?

i read these perameters , main function @ here , here. still don't understand how these works.

please explain .

edit: mentioned in comments if change code

printf("%d %s",argc,argv[argc-1]); 

now i'm getting whole path of file f:\file path

so mean argv[0] location of file in drive?

it not defined in c standard, on unix argv[0] name of executable. argv[1] first argument, etc. think true, of time, on microsoft's dos , windowing oses.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -