Skip to content

Commit

Permalink
update(cpp-stl): usage of iomanip
Browse files Browse the repository at this point in the history
issue #104
  • Loading branch information
sabertazimi committed Nov 23, 2018
1 parent af05970 commit e9b3c88
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions language/cpp/cppBasicNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
- [异常对象的析构](#异常对象的析构)
- [多态](#多态)
- [STL](#stl)
- [Input Output](#input-output)
- [iomanip STL API](#iomanip-stl-api)
- [Container](#container)
- [Container Choosing](#container-choosing)
- [empty/size](#emptysize)
Expand Down Expand Up @@ -803,6 +805,31 @@ c.speak("Hello World!") // => "Child: Hello World!"

- 工作方式: copy in, copy out

### Input Output

#### iomanip STL API

output format

```cpp
#include <iostream>
#include <iomanip>

int main() {
std::cout << "default fill: " << std::setw(10) << 42 << '\n'
<< "setfill('*'): " << std::setfill('*')
<< std::setw(10) << 42 << '\n';

std::cout << rd.name << " 0x"
<< std::setfill('0') << std::setw(16) << std::hex
<< get_register_value(m_pid, rd.r) << std::endl;
}

// Output:
// default fill: 42
// setfill('*'): ********42
```

### Container

- 序列容器: vector string deque list
Expand Down

0 comments on commit e9b3c88

Please sign in to comment.