C语言已经学完了,但是感觉有点缺少实践,有没有人可以告诉我,怎么检验和巩固一下自己的学习成果
C语言已经学完了,但是感觉有点缺少实践,有没有人可以告诉我,怎么检验和巩固一下自己的学习成果
2018-05-03 17:24
2018-05-03 17:53
~

2018-05-03 18:00
2018-05-03 19:45
2018-05-03 20:21
2018-05-04 08:57
2018-05-04 09:08
程序代码:
#include<stdio.h>
#define __COPY_ARR( A,B,TYPE ) \
do \
{ \
struct __COPY_ARR_S \
{ \
TYPE s[sizeof (A)/sizeof (TYPE)]; \
}*const __COPY_TEMP__=( const struct __COPY_ARR_S* )&A; \
*__COPY_TEMP__=( const struct __COPY_ARR_S )B; \
}while (0)
void test1( void );
void test2( void );
int main( void )
{
test1();
test2();
return 0;
}
void test1( void )
{
const int a[3]=
{
9,
8,
7
};
int b[3];
__COPY_ARR(b,a,int);
printf("%d\n",b[0]);
printf("%d\n",b[1]);
printf("%d\n",b[2]);
puts("");
}
void test2( void )
{
const double a[2][2]=
{
{1.1,2.2},
{3.3,4.4}
};
double b[2][2];
__COPY_ARR(b,a,double);
printf("%.1f\n",b[0][0]);
printf("%.1f\n",b[0][1]);
printf("%.1f\n",b[1][0]);
printf("%.1f\n",b[1][1]);
}
程序代码:
#include<stdio.h>
#define __MACRO \
do \
{ \
struct \
{ \
char a; \
char b; \
int c; \
}const s1= \
{ \
0x1, \
0x2, \
0x3 \
}; \
\
printf("%#x\n",s1+0); \
}while (0)
int main( void )
{
#pragma pack(push,1)
__MACRO;
#pragma pack(pop)
__MACRO;
return 0;
}0;
}
~[此贴子已经被作者于2018-5-4 12:23编辑过]

2018-05-04 09:24
2018-05-07 19:23