:
void main(void){
int age[10];
............
sum (age);
..........
}
void sum (int year[]){}
int year[] - age. .
void sum (int*pm){}.
pm+3 <=> year[3] <=> age[3] pm[3].
int* pm int pm[]; -
: .
float var (int*pm, int i){ //
//.
float sum=0;
int k;
for (k=0; k<i; k++)
sum+=*pm++; //*(pm+k) pm[k]
returm (sum/i); //
} // .
void main(void){
int mas[3][4]={ {1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12} };
int i;
for (i=0; i<3; i++)
printf (" %d %4.2f.\n", i+1,
var(mas[i],4));
}
, . .
.
float var(int mas[][4]),.. 4 .
13.8 void *
void *vptr; , vptr - , " type" . " type1" " type2", type1 type2 , . type1 void, .
int max(void *, void *);
void main(void) {
int x=5, y=10;
int k=max((void *)&x, (void *)&y);
(k==0)?puts(x>y): puts(x<y);
}
int max(void *a,void *b) {
return((*a>*b)?0:1);
}
, - , . +'\0' . , \".
. , . , . %s.
char mas[] = " ";
mas - -> &m[0] *mas==''.
.
char *str = " ";
char str[]= " ".
, .
void main(void){
char* mesg=" ";
char* copy;
copy = mesg; .
|
|
printf ("%S", copy);
printf ("%S", mesg);
}
char* name;
scanf ("%S", name); // !!! .
char name [81]; //
1. .
char mas[80];
scanf("%S",mas);
2. ,
char mas[4][81];
for (i=0; i<4; i++)
sanf("%S", mas[i]); // &mas[i][0]
3. .
char m1[] = " "; //
// + 1 '\0'.
4. .
char m2[50] = " "; //18+1
5. char m3[]={'c', 'm', 'p', 'o', 'k', 'a', '\o'};
6. :
char masstr[3][16]={" ",
" ",
" " };
*masstr[0]=='';
*masstr[1]=='B';
*masstr[2]=='';
printf(\n %c, *masstr[i]); //
printf(\n %s, *(masstr+i)); //
printf(\n %u, masstr[i]); //
7. .
static char *masstr[3]= {" ",
" ",
" " };
.
int* parray[5]; //5 .
*parray[3] - //3- .
char *keywords[5]={"ADD", "CHANGE", "DELETE", "LIST", "QUIT"};
:
keyword[0] 10000 ADD\0 4
keyword[1] - 10004 CHANGE\0 7
keyword[2] - 10011 DELETE\0 7
for (i=0; i<5; i++)
printf("%s", keywords[i]); //
char *key[3],**pt; //
pt=key;
printf(%s %d\n,*pt,**pt); //
for (i=0; i<5; i++)
printf(%c ,**(pt+i)); //
for (i=0; i<3; i++)
printf(%c ,*(*pt+i)); //