For starters, in accordance with the C standard, the main function without parameters should be declared as
int main( void )
To output type objects, doubleyou should use at least the conversion specifier %finstead %d. Otherwise, the function printfhas undefined behavior.
Now about pointers.
T, T - , ,
T x;
T *
, , T.
#include <stdio.h>
void set1( T *x )
{
}
int main(void)
{
T x;
set1( &x ) ;
return 0;
}
, T . T ?
:
typedef double T[2];
, typedef , .
#include <stdio.h>
typedef double T[2];
void set1( T *x )
{
}
int main(void)
{
T x;
set1( &x ) ;
return 0;
}
, , &x ?
double ( *x )[2]. , double **, . .
,
#include <stdio.h>
void set1( double ( *x )[2] )
{
(*x)[0] = (*x)[1] = 1.0;
}
int main(void)
{
double x[2];
set1( &x ) ;
printf( "%f\n%f\n", x[0] , x[1] );
return 0;
}
, double **, ,
#include <stdio.h>
void set1( double **x )
{
(*x)[0] = (*x)[1] = 1.0;
}
int main(void)
{
double x[2];
double *p = x;
set1( &p ) ;
printf( "%f\n%f\n", x[0] , x[1] );
return 0;
}
p double * double ** .
double *, .
#include <stdio.h>
void set1( double *x )
{
x[0] = x[1] = 1.0;
}
int main(void)
{
double x[2];
set1( x ) ;
printf( "%f\n%f\n", x[0] , x[1] );
return 0;
}