码迷,mamicode.com
首页 > 编程语言 > 详细

从语言字符串对齐

时间:2020-02-24 13:03:49      阅读:54      评论:0      收藏:0      [点我收藏+]

标签:return   int   str   include   长度   字符   输出   div   print   

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

#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;
}

从语言字符串对齐

标签:return   int   str   include   长度   字符   输出   div   print   

原文地址:https://www.cnblogs.com/WheatThump/p/12356256.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!