【c学习-5】

 

 下表列出了c程序中常见的保留字

 

 

转义字符常量

 

 

 

#include<stdio.h>
extern myFunction();     //全局变量储存类,对所有文件共享 
int main(){
    
    //int x;
    
    auto int x;              //默认储存类 
    x=10;
    //printf("x=%d\n",x); 
    register char y;           //寄存器储存类 
    printf("int size=%d\n\f",sizeof(int));
}



#include<stdio.h>
extern x;
void myFunction(){
    printf("x=%d\n",x);
    
}

 

 

 

 

 

#include<stdio.h>
extern myFunction();     //全局变量储存类,对所有文件共享 
int main(){
    
    /* 
    //int x;
    short z;
    auto int x;              //默认储存类 
    x=10;
    //printf("x=%d\n",x); 
    register char y;           //寄存器储存类 
    printf("int size=%d\n\f",sizeof(int));
    y=1>2;
    printf("%d\n",y);
    z=(x==10)?18:19;              //条件表达式 
    
    printf("z=%d\n",z);
*/
struct play{
    int id:2;
    char project:4;   // 位 域 
    int age:6;    
} xiaoming;
xiaoming.id=2;
printf("%d\n",xiaoming.id);  
struct play xiaoHong;
xiaoHong.id=1;
xiaoHong.project="ball";
printf("xiaoHong.id=%d\n",xiaoHong.id);
printf("xiaoHong.project=c\n",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\n",buff);
fgets(buff,255,(FILE*)fp);
printf("2:%s\n",buff);
fclose(fp);
/*
FILE *fp;             //定义文件指针 

fp=fopen("1.txt","w+");    //以读写方式打开文件 
fprintf(fp,"hello world\n");   //打印和写入文件 
fputc("hello world",fp);
fclose(fp);

*/

    /*
    Table x;
    x.id=1;
    strcpy(x.name,"lp");
    strcpy(x.money,"30");    
    printf("x.id=%d\n",x.id);
    printf("x.name=%s\n",x.name);
    printf("x.money=%s\n",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\n")
          //    \   宏延续符 
           //    #   字符常量化运算符                     
            // ##  标记粘贴运算符 
int main(){
    printf("%s\n",x);
    h_var(lp,pl);
    return 0;
    
}
    

 

posted on 2018-08-16 11:34  activecode  阅读(166)  评论(0编辑  收藏  举报

导航