f.h
#define Area 1000 struct student{ char *last_name; int student_id; char grade; int a; };
h.c
#include <stdio.h> #include "f.h" #define PI 3.1415926 #define LIMIT 20 struct employee_data { int a; }; int main(void) { //引用 printf("%d\n",Area); //字符 char c; c='A'; int age; char first,end; printf("%c\n",c); printf("%3c\n",c); printf("%3c\n",'A'); //scanf("%d",&age); //printf("%d\n",age); //scanf("%c",&first); //printf("%c\n",first); char *p1; p1=&c; printf("%c%d%c\n",*p1,*p1+1,*p1+2); //printf("%c",'\a');//响铃 //char d=getchar();//putchar() //printf("%c\n",d); const int p_sea=20; //p_sea=30;会报错,向只读变量赋值 float x,y; x=2.0; y=3.0; printf("%f\n",x*y); printf("%f\n",PI); double d1=1.123456789; printf("%lf\n",d1); int i=1,sum=0; while (i<7){ sum=sum+i; i++; } printf("%d\n",sum); int sz[3]={23,15,78}; sz[1]=2; printf("%d\n",sz[1]); //求数组长度 int count=sizeof(sz)/sizeof(int); printf("%d\n",count); typedef int myint; myint i1=9; printf("%d\n",i1); printf("%d\n",sizeof(i1));//输出4 int是4位 //指针和数组关系 int sz1[4]={40,82,67,11}; int *p; p=sz1; printf("*p %d\n",*p);//40 printf("*p+1 %d\n",*p+1);//41 printf("*p+2 %d\n",*p+2);//42 printf("*p %d\n",*p);//40 printf("*p+1 %d\n",*(p+1));//82 printf("*p+2 %d\n",*(p+2));//67 struct card{ int pips; char suit; }c1,c2; c1.pips=3; c1.suit='5'; c2=c1; printf("struct c2.pips: %d\n",c2.pips); typedef struct{ int re; int im; }complex; complex as,ac[2]; as.re=89; ac[0].re=1; ac[1].re=2; printf("struct ac[0].re: %d\n",ac[0].re); printf("struct ac[1].re: %d\n",ac[1].re); printf("struct ac[0].re: %d\n",ac[0].re); struct student tmp; tmp.last_name="Canada"; tmp.grade='A'; tmp.student_id=122; tmp.a=0; printf("struct tmp.last_name: %s\n",tmp.last_name); struct employee_data e1; e1.a=12; int e11=getdata(e1); printf("struct e11: %d\n",e11); int e12=getdata_add(&e1); printf("struct e12: %d\n",e12); //与或非 int y1=3; int y2=0; int y3=y1&y2; printf("y3 &: %d\n",y3); printf("-9 >>31: %d\n",abs(-9)); #undef __FD_SETSIZE #define __FD_SETSIZE 1024 printf("#define: %d\n",__FD_SETSIZE); return 0; } //一个负数右移31位后会变成 0xffffffff,一个正数右移31位则为 0x00000000 //0xffffffff ^ a + a = - 1 //因为 1011 ^ 1111 = 0100 异或1111其实是把a的0和1进行了颠倒。 int abs(int x) { return (x ^ (x >> 31)) - (x >> 31); } int getdata(struct employee_data e) { return e.a; } int getdata_add(struct employee_data *e) { return e->a; }