回覆列表
  • 1 # 變餅檔

    #include<stdio.h>

    typedef struct{

    char buf[10];

    char ptr;

    }A;

    main()

    {

    char *s = "adcABC+-/*123";

    char *p,tmp;

    A upper,normal,num,other;

    int i,len;

    memset(&upper,0,sizeof(A));

    memset(&normal,0,sizeof(A));

    memset(&num,0,sizeof(A));

    memset(&other,0,sizeof(A));

    len = strlen(s); //獲取源字串長度

    p = s;

    for (i=0; i<len; i++)

    {

    tmp = p[i];

    if ((tmp>="A") && (tmp<="Z")) //大寫字母

    upper.buf[upper.ptr++] = tmp;

    else if ((tmp>="a") && (tmp<="z")) //小寫字母

    normal.buf[normal.ptr++] = tmp;

    else if ((tmp>="0") && (tmp<="9")) //數字

    num.buf[num.ptr++] = tmp;

    else //其它字元

    other.buf[other.ptr++] = tmp;

    }

    printf("%s",upper.buf);

    printf("%s",normal.buf);

    printf("%s",num.buf);

    printf("%s",other.buf);

    getchar();

    }

  • 中秋節和大豐收的關聯?
  • 開機後顯示屏白屏,無顯示?