Am I correct in description of the following code
Does the comment correcty describe what I am doing??Code:int array[5]={0};
int *ptr=array;
...
scanf("%d", &*(ptr + i) );/* Store input at the address of the value at (ptr + i)*/
Printable View
Am I correct in description of the following code
Does the comment correcty describe what I am doing??Code:int array[5]={0};
int *ptr=array;
...
scanf("%d", &*(ptr + i) );/* Store input at the address of the value at (ptr + i)*/
I swear I usedand the compiler complained about something. It is working now thoughCode:scanf("%d", (ptr + i) );
If it's 'C' you're compiling and not C++, the compiler should complain that scanf() has not been defined, but in 'C", it will allow the compile to be successful (since missing function declarations are OK in 'C"). You are missing the include for <stdio.h> in your sample.
That's why when posting code, you better post everything, including the headers that you included. If it really is 'C' and not C++ that you're compiling, a missing header can make the difference between a program that compiles OK and works when run and a program that compiles OK and fails to run correctly.
Regards,
Paul McKenzie
Yes it is ' C ' that I am using. I could not find the "Plain C" board.
I was looking for clarification on what I was doing with the pointers and derefrencing. Making sure that I was describing the statement correctly. Thanks guys.