菜鸟的博客

纵有疾风起,人生不言弃。

导航

2023.7.3

## 输入带空格的字符串

~~~ c++
1.
#include <string.h>
string s;
getline(cin,s);

2.
#include <cstring>
#include <stdio.h>
char a[1024];
gets(a);
int len = strlen(a);//得到数组的实际长度

~~~

## 填充输入

~~~java
setw(int n)//用来控制输出间隔
//例:cout<<'s'<<setw(3)<<'a'<<endl;
setfill(char c)//用来填充输出
//例:cout<<setfill('*')<<setw(3)<<'a'<<endl;
    //输出为:**a
~~~

 

posted on 2023-07-03 17:45  hhmzd233  阅读(12)  评论(0)    收藏  举报