Dear Members,
I have a very puzzling problem. I have a tiny C program that I want to run with the following command line argument at the prompt:
>> Pointers 3
Pointers.c looks like:
void main(int count, int *argv[]) {
int *ptr;
ptr = &argv[1];
printf("\n*** Parameter passed is: %d \n", *ptr);
}
So I want the printf to print the '3' I am passing, but instead a get a weird number!!! I tried to remove the '&' when I do the ptr assignment but nothing seems to work. I thought I had understood pointers :-( Can you help?
--Cecilia.
I have a very puzzling problem. I have a tiny C program that I want to run with the following command line argument at the prompt:
>> Pointers 3
Pointers.c looks like:
void main(int count, int *argv[]) {
int *ptr;
ptr = &argv[1];
printf("\n*** Parameter passed is: %d \n", *ptr);
}
So I want the printf to print the '3' I am passing, but instead a get a weird number!!! I tried to remove the '&' when I do the ptr assignment but nothing seems to work. I thought I had understood pointers :-( Can you help?
--Cecilia.