C
Chad
Given the following...
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("argv[0] is: %s\n", argv[0]);
printf("(*++argv)[0] is: %c\n", (*++argv)[0]);
printf("argv[0] + 1 is: %s\n", (argv[0]+1));
return 0;
}
This produces the following after I compile and run it.
$ ./entab2 -10
argv[0] is: ./entab2
(*++argv)[0] is: -
argv[0] + 1 is: 10
How come, under the GNU debugger, I can get '-' the print if I do
something like print *(argv)[0]. But I can't get the '1' to print when
I do print *(argv)[1]?
(gdb) print *(argv)
$15 = 0xbfb7e9cf "-10"
(gdb) print *(argv)[0]
$16 = 45 '-'
(gdb) print *(argv)[1]
Cannot access memory at address 0x0
(gdb)
I mean, isn't "-10" just all one string?
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("argv[0] is: %s\n", argv[0]);
printf("(*++argv)[0] is: %c\n", (*++argv)[0]);
printf("argv[0] + 1 is: %s\n", (argv[0]+1));
return 0;
}
This produces the following after I compile and run it.
$ ./entab2 -10
argv[0] is: ./entab2
(*++argv)[0] is: -
argv[0] + 1 is: 10
How come, under the GNU debugger, I can get '-' the print if I do
something like print *(argv)[0]. But I can't get the '1' to print when
I do print *(argv)[1]?
(gdb) print *(argv)
$15 = 0xbfb7e9cf "-10"
(gdb) print *(argv)[0]
$16 = 45 '-'
(gdb) print *(argv)[1]
Cannot access memory at address 0x0
(gdb)
I mean, isn't "-10" just all one string?