c - segmentation fault and argv, argc -
i made code prints out input:
int main(int argc, char *argv[]) { printf("%c", *argv[1]); return 0; }
when put ab
, abcdef
, ac
, *cf
, works well, when put **
or $$
returns 2, , when put $a
, $k
, , on, generates segmentation error. wonder why doesn't print out letters put.
assuming you're running linux or other kind of unix flavour, $a
refers environment variable a. expanded shell, , since didn't set value, becomes empty.
to literal string $a
, you'll have escape argument - depending on shell you're using, try single or double quotes or escaping $
backslash \
.
Comments
Post a Comment