可变输出字节程序
#include <stdio.h>int main(void)
{
int first_name_width,second_name_width;
char first_name[20];
char second_name[30];
printf("please enter your second name;\n");
scanf("%s",second_name);
printf("please enter your first name;\n");
scanf("%s",first_name);
printf("please enter your first name width and second name width:\n");
scanf("%d,%d",&first_name_width,&second_name_width);
printf("%s %s\n",first_name,second_name);
printf("%*d %*d\n",first_name_width,strlen(first_name),
second_name_width,strlen(second_name));
printf("%s %s\n",first_name,second_name);
printf("%-*d %-*d",first_name_width,strlen(first_name),
second_name_width,strlen(second_name));
getch();
}
输出形式: