下表列出了c程序中常见的保留字
转义字符常量
#include<stdio.h> extern myFunction(); //全局变量储存类,对所有文件共享 int main(){ //int x; auto int x; //默认储存类 x=10; //printf("x=%d ",x); register char y; //寄存器储存类 printf("int size=%d f",sizeof(int)); } #include<stdio.h> extern x; void myFunction(){ printf("x=%d ",x); }
#include<stdio.h> extern myFunction(); //全局变量储存类,对所有文件共享 int main(){ /* //int x; short z; auto int x; //默认储存类 x=10; //printf("x=%d ",x); register char y; //寄存器储存类 printf("int size=%d f",sizeof(int)); y=1>2; printf("%d ",y); z=(x==10)?18:19; //条件表达式 printf("z=%d ",z); */ struct play{ int id:2; char project:4; // 位 域 int age:6; } xiaoming; xiaoming.id=2; printf("%d ",xiaoming.id); struct play xiaoHong; xiaoHong.id=1; xiaoHong.project="ball"; printf("xiaoHong.id=%d ",xiaoHong.id); printf("xiaoHong.project=c ",xiaoHong.project); }
#include<stdio.h> #include<string.h> /* typedef struct totalTable{ //typedof为结构体定义别名 ; int id; char name; int money; }Table; */ int main(){ FILE *fp; char buff[255]; fp=fopen("1.txt","r") ; fscanf(fp,"%s",buff); printf("1:%s ",buff); fgets(buff,255,(FILE*)fp); printf("2:%s ",buff); fclose(fp); /* FILE *fp; //定义文件指针 fp=fopen("1.txt","w+"); //以读写方式打开文件 fprintf(fp,"hello world "); //打印和写入文件 fputc("hello world",fp); fclose(fp); */ /* Table x; x.id=1; strcpy(x.name,"lp"); strcpy(x.money,"30"); printf("x.id=%d ",x.id); printf("x.name=%s ",x.name); printf("x.money=%s ",x.money); */ }
#include<stdio.h> #if !defined(x) //标示符定义有判断 #define x "hello world" #endif #define h_var(a,b) printf(#a " and " #b ":I love you ") // 宏延续符 // # 字符常量化运算符 // ## 标记粘贴运算符 int main(){ printf("%s ",x); h_var(lp,pl); return 0; }