This commit is contained in:
LingZhaoHui 2020-07-13 20:07:29 +08:00
parent 9749d1d31a
commit 467d7c540b
1 changed files with 36 additions and 0 deletions

36
c_expert/chapter3/s_tag.c Normal file
View File

@ -0,0 +1,36 @@
#include <stdio.h>
#define SIZE 3
struct s_tag {
int a [SIZE];
};
struct s_tag orange, lime, lemon;
struct s_tag twofold (struct s_tag s) {
int j;
for ( j = 0; j < SIZE; j++ )
{
s.a[j] *= 2;
}
return s;
}
int main()
{
int i;
for ( i = 0; i< SIZE; i++ )
{
lime.a[i] = 1;
}
lemon = twofold(lime);
orange = lemon;
for ( i = 0; i< SIZE; i++ )
{
printf("lime.a[%d]=%d\n", i, lime.a[i]);
printf("lemon.a[%d]=%d\n", i, lemon.a[i]);
printf("orange.a[%d]=%d\n", i, orange.a[i]);
}
return 0;
}