Why, when passing an array element to a function through a ParamArray, does a varpointer arrive in the function?

I think, it is a carelessness in “C”. You get such an error with

#include <stdio.h>

int main(int argc, char **argv)
{
   int *X;
   int i;
   
   i = 7;
   X = &i;
   
   printf("%d\n", X);
   printf("%d\n", *X);
   
   return(0);
}

Elaboration:

“C” is a kind of abstract assembler. You have to understand the concept of accessing memory through addresses (or pointers). With

int i;

you declare a variable, that holds an integer (the number of bits of this integer depends on the compiler). With

i = 7;

you define the value of this variable in memory (here 7). With

int *X;

you declare a variable, which holds a value of a pointer (the number of bits of a pointer depends on the compiler; often the number of bits of an integer and a pointer are equal) to a location, which contains an integer. With

X = &i;

you define the value of the pointer X as the address of the variable i. With

*X

you have access to the (integer) value in memory of the location, where X points to. With

printf("%d\n", X);

you print the value of the pointer X (interpreted as integer). With

printf("%d\n", *X);

you print the (integer) value of the memory, where X points to.

I believe, someone forgot a “*”.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)