C++中的流操縱器的showpoint()方法用於為指定的str流設置showpoint格式標誌。該標誌始終顯示浮點值及其十進製值。
用法:
ios_base& showpoint (ios_base& str)
參數:此方法接受str作為參數,這是格式標誌受影響的流。
返回值:此方法返回設置了showpoint格式標誌的流str。
範例1:
// C++ code to demonstrate
// the working of showpoint() function
#include <iostream>
using namespace std;
int main()
{
// Initializing the floating values
double n1 = 10;
double n2 = 20.0;
cout.precision(5);
// Using showpoint()
cout << "showpoint flag:"
<< showpoint
<< n1 << endl
<< n2 << endl;
return 0;
}
輸出:
showpoint flag:10.000 20.000
範例2:
// C++ code to demonstrate
// the working of showpoint() function
#include <iostream>
using namespace std;
int main()
{
// Initializing the floating values
double n3 = 30.1223;
cout.precision(5);
// Using showpoint()
cout << "showpoint flag:"
<< showpoint
<< n3 << endl;
return 0;
}
輸出:
showpoint flag:30.122
參考: http://www.cplusplus.com/reference/ios/showpoint/
相關用法
- C++ ios manipulators right()用法及代碼示例
- C++ ios manipulators oct()用法及代碼示例
- C++ ios manipulators hex()用法及代碼示例
- C++ ios manipulators dec()用法及代碼示例
- C++ ios manipulators noshowbase()用法及代碼示例
- C++ ios manipulators showbase()用法及代碼示例
- C++ ios manipulators noshowpos()用法及代碼示例
- C++ ios manipulators fixed()用法及代碼示例
- C++ ios manipulators left()用法及代碼示例
- C++ ios manipulators noskipws()用法及代碼示例
- C++ ios manipulators boolalpha()用法及代碼示例
- C++ ios manipulators nounitbuf()用法及代碼示例
- C++ ios manipulators skipws()用法及代碼示例
- C++ ios manipulators internal()用法及代碼示例
- C++ ios manipulators showpos()用法及代碼示例
注:本文由純淨天空篩選整理自guptayashgupta53大神的英文原創作品 ios manipulators showpoint() function in C++。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。