Tuesday, 6 August 2013

pointer to one single char of a two dimensional array

pointer to one single char of a two dimensional array

as far as I know an array like
int example[10]
is nothing else than a pointer to the first element in this array.
char* argv[]
is an array of pointers. So that should be pointers which point to other
pointers.
I have following problem now:
int main(int argc, char* argv[])
{
double ptrarg2=argv[2][1];
printf("beginletter=%c\nbeginpos=%d\n",&ptrarg2, ptrarg2);
return 0;
}
i am starting the program with ./program test and expecting the output to be:
beginletter=c
beginpos=123213123
while 123213123 should be the adress where the c is actually stored.
i am actually getting:
beginletter=
beginpos=0
what am I doing wrong? Thank you in advance!

No comments:

Post a Comment