1:
#include <stdio.h>
int main(void)
{
char name[40];
char surname[40];
printf("Plese input your first name:");
scanf("%s", name);
printf("Plese input your last name");
scanf("%s", surname);
printf("Hello! %s,%s", name, surname);
return 0;
}
2:
printf("\"%s\"\n",name)
printf("\"%20s\"\n",name)
printf("\"%-20s\"\n",name)
通过width 来定义,指定宽度参数,打印名字字符串
3
#include<stdio.h>
int main(void)
{
float a;
printf("输入一个浮点数\n");
scanf_s("%f", &a);
printf("The input is %.1Lf or %.Le\n", a);
printf("The input is %.3lf or %.3Le\n",a);
return 0;
}
4
#include <stdio.h>
int main(void)
{
int wname, wsurname;
char name[40];
char surname[40];
printf("Plese input your first name:\n");
scanf_s("%s", name,sizeof(name));
printf("Plese input your last name:\n");
scanf_s("%s", surname,sizeof(surname));
wname = printf("%s", name);
printf(" ");
wsurname = printf("%s", surname);
printf("\n%*d %*d ", wname, wname, wsurname, wsurname);
//printf("\n%*d %*d ", strlen(name), strlen(name), strlen(surname), strlen(surname));
return 0;
}
标签:Plese,surname,name,scanf,printf,字符串,格式化,解析,input From: https://blog.csdn.net/lly_b/article/details/140716619