首页 > 编程知识 正文

c需要标准库,android标准c库

时间:2023-05-06 02:00:33 阅读:172987 作者:3921

用c语言

头文件: #include iomanip

描述:是I/O流控制头文件,类似于c中的格式输出

控件的作用dec设置整数十进制hex设置整数十六进制oct设置整数八进制setbase(n )设置整数n进制(n=8,10,16 ) setfill(n ) n )设置字符填充。 c可以是文字或文字变量

setprecision(n )设置浮点数有效数字n位setw(n ) n )设置字段宽度n位setiosflags (IOs 33603360 fixed )设置浮点数setiosflags (IOs ) 336033: scscsch 固定,以便科学地表示setiosflags(IOs:3360left )输出左对齐setiosflags (IOs :3360 right )输出右对齐setiosflags (IOs 33603: skip ws )。 前导空格setiosflags ) IOS3360360skipws将被忽略。如果resetiosflags (IOs :3360 show pos )输出正数,则显示“”的编号并设置IOs 33603360 show pos

另外,有效位数默认为6位,即setprecision(6),小数点前后的位数为6位有效数字(注意要四舍五入)。

另外,科学计数法输出e和16进制输出的缺省值为小写,要改为大写需要追加uppercase

另一方面,如果setw(n )的设定宽度实际宽度大于设定的宽度,则setw函数此时无效。

以下是测试程序:

# include iostream # includeiomanipusingnamespacestd; int main () {double PI=3.141592654; coutPIendl; coutsetprecision(2) PIendl; coutfixedsetprecision(2) PIendl; coutsetfill('* ' ) setw ) setprecision ) PIendl; coutsetfill('* ' ) setw ) setprecision ) leftPIendl; coutscientificsetprecision(10 ) PIendl; coutscientificuppercasesetprecision (10 ) PIendl; 返回0; }

结果如下。

相关课件,更多内容在课件中,收集在互联网上:下载1

iomanip头文件的声明如下所示。

//iomanipstandardheader # pragma once # ifndef _ iomanip _ # define _ iomanip _ # ifndef RC _ invoked # include istream # 3 ) endif/* _ MSC _ ver */_ STD _ begin//template struct _ fillobjtemplateclass _ elem struct _ fill obj {/stempll //templatefunctionsetfilltemplateclass _ elem inline _ fill obj _ elem _ clr call _ or _ cdeclsetfill (elem _ ch ) templp class _ traitsinlinebasic _ istream _ elem,_ traits _ _ clr call _ or _ cdecl operator (bassecloperator )。 const _ fill obj _ elem _ manip (/setfillcharacterininputstream _ istr.fill ) _manip._fill ); 返回(istr ); }templateclass _Elem,class _ traitsinlinebasic _ ostream _ elem,_ traits _ clr call _ or _ cdecl operator (basssecech ) const _ fill obj _ elem _ manip (/setfillcharacterinoutputstream _ ostr.fill ) _manip._fill ); 返回(ostr ); (/template struct _ smaniptemplateclass _ arg struct _ s manip (/storefunctionpointerandargumentvalue _ s manip )/voidfunctionpointerandargumentvalue (s manip ) ) _arg_val(:_pfun ) left )、_ manarg (val )//constructfromfrom //the argument value}; templateclass _Elem、class _Traits、class _ arginlinebasic _ istream _ elem, _ traits _ _ clr call _ or _ cdecl ol const _ s manip _ arg _ manip (/extractbycallingfunctionwithinputstreamandargument }templateclass _Elem,class _Traits,class _ arginlinebasic _ ostream _ elem, _ traits _ _ clr call _ or _ cdec all _ or _ cdec all const _ s manip _ arg _ manip (/insertbycallingfunctionwithouthoutoutputputtpup (/instantiation s _ mrt imp2_ smanipios _ base :3360 fmt flags _ cdeclresetiosflags (IOs _ base 3360360 fmt flags ) cdeclress smanipios _ base :3360 fmt flags _ cdeclsetiosflags (IOs _ base 33603360 fmt flags ); _ mrt imp2_ smanipint _ _ cdecl set base (int; _ mrt imp2_ smanipstreamsize _ _ cdeclsetprecision (stream size; _ mrt imp2_ smanipstreamsize _ _ cdecl setw (stream size ); _ STD _ end # ifdef _ MSC _ ver # pragma warning (pop ) pragmapack ) pop ) endif/* _ MSC _ ver */# endif/* RC 1992 consultyourlicenseregardingpermissionsandrestrictions.v 5.023360009 * % permissionsandrestrictions.v 5.0236000009

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。