【c学习-3】

---恢复内容开始---

 

#include<stdio.h>
int main(){
    int a[5]={1,2,3,4,5};
    int i=0;    
    for(i=0;i<=5;i++){
        printf("%d\n",a[i]);
        if(i==4){
            printf(",");
        }
        
    } 
    putchar("\n"); 
}


#include<stdio.h>
int main(){
    int arry[3][4]={{1,2,3,4},{5,6,7,8},{0,0,0,9}};
    int i,j=0;
    for(i=0;i<3;i++){
        for(j=0;j<4;j++){
            printf("arry[%p][%p]=%p",j,j,arry[i][j]);
        }
        printf("\n");
    }
        
    
}

 





#include<stdio.h>
int main(){
    /*int i=0;
    int a[10]={'H','e','l','l','o'};
    printf("%ld\n",sizeof(a));
    char b[10]="hello";
    memset(b,'a',10);  //覆盖字符函数 
    for(i=0;i<10;i++){
        printf("%c\n",b[i]);
    }
    int length=strlen(b);  //字符长度函数 
    printf("length=%d\n",length);
    */
    char x[]="123";
    char y[]="12";
    char z[20]=""; 
    int diff=strcmp(x,y);  //字符比较函数 
    printf("%d\n",diff);    
    //strcpy(z,y);              //字符复制函数 
    //printf("z=%s\n",z);
    strncpy(z,x,1);
    printf("z=%s\n",z);        //字符复制函数升级版 
    strcat(x,y);             //字符拼接函数 
    printf("x=%s\n",x);
    
    
    /*    if(diff>=0){
        printf("x>y");
    }else if(diff<0){
        printf("x<y");
    }else{
        printf("x=y");        
    }

*/
}

#include<stdio.h>
int funX(int a,int b){
    return a+b;
}
int main(){
    
    funX(1,2);
}

 
























 

 

 

 

 

---恢复内容结束---

posted on 2018-08-14 17:14  activecode  阅读(160)  评论(0编辑  收藏  举报

导航