从语言字符串对齐

可采用*抑制赋值,为后面输出进行格式设定。

#include<string.h>
strlen函数其读出长度为整形int。
#include<stdio.h>
#include<string.h>
int main(void)
{
    char x[40];
    char m[40];
    int a,b;
    printf("srx:\n");    //采用*作为占位符 可以用后面位数来表示其占位数量 strlen函数其读出长度为整形int
    scanf("%s",x);
    printf("srm;\n");
    scanf("%s",m);
    printf("%s %s\n",x,m);
    a=strlen(x);
    b=strlen(m);
    printf("%*d %*d\n",a,a,b,b);
    printf("%-*d %-*d",a,a,b,b);
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/WheatThump/p/12356256.html
今日推荐