Hello,
I wrote this simple program which prints all the arguments given to a program.
My code is straightforward and this is it
Code:
#include <stdio.h>
#include <malloc.h>
int i = 0;
int main(int argc, char** argv)
{
printf("\nargc == [%d]",argc);
printf("\nthe arguments are ");
for(i=0;i<argc;i++)
{
printf("\nargv[%d] == [%s]",i,*(argv+i));
}
return 0;
}
And this is what I see in gdb
Code:
argc == [4]
the arguments are
argv[0] == [/home/Desktop/gdb/five/a.out]
argv[1] == [hello]
argv[2] == [world]
0x00007ffff7a5a30d in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) n
Single stepping until exit from function __libc_start_main,
which has no line number information.
argv[3] == [again][Inferior 1 (process 2566) exited normally]
My question is : why is is that only the last argument is printed seperately, like, after a line, though there is nothing in code which tells it to do so ?
Or, is this the way for the last line of every program ?
Bookmarks