call the main function in the system console, after the operation how garbled words??????
CodePudding user response:
Need to analyze the types of argv, type is char * []; , the pointer array, from the host's case, the original poster of the argv array length is 5.You need to know about the argv++; How many bytes are offset, the original poster to achieve argv [0] - & gt; Argv [1] - & gt; Argv [2],,, this migration, the amount of deviation is sizeof (argv [0]).
But argv++; That is offset 5 * sizeof (argv [0]). Have crossed, so shows that the code is should be crossing the line is undefined behavior;
Char * p=argv [0].
While (arg c & gt; 0 {
P++;
Printf (" % s \ n ", p);//also shouldn't be here argv, should also be argv [0] orargv
[I]?Arg c -;
}
int I=0;
While (I & lt; Arg c) {
Printf (" % s \ n ", argv [I]);
i++;
}
For your reference ~
CodePudding user response:
That is when the system calls will not pass argv first address to the main function is, in the program will still have to define a pointer to argv first address rightCodePudding user response:
Argv equivalent & amp; Argv [I], in order to achieve a result, the upstairs needPrintf (" % s \ n ", * argv);