CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C++ Builder >  基础类

bcb中如何使用cout和cin来控制输入输出啊?

楼主kkklmn(小虫)2005-06-30 20:11:04 在 C++ Builder / 基础类 提问

那位仁兄能给在下指点一下? 问题点数:20、回复次数:9Top

1 楼ynlzl(小百姓)回复于 2005-06-30 22:10:33 得分 0

我也不会,帮顶一顶。Top

2 楼songhtao(三十年孤独)回复于 2005-07-01 08:37:03 得分 0

#include<iostream>  
  #include<iomanip>  
  void   main   (   )  
  {  
      using   namespace   std;  
      int   i;  
      float   f;  
       
      //   read   an   integer   and   a   float   from   stdin  
      cin   >>   i   >>   f;  
      //   output   the   integer   and   goes   at   the   line  
      cout   <<   i   <<   endl;  
      //   output   the   float   and   goes   at   the   line  
      cout   <<   f   <<   endl;        
      //   output   i   in   hexa  
      cout   <<   hex   <<   i   <<   endl;  
      //   output   i   in   octal   and   then   in   decimal  
      cout   <<   oct   <<   i   <<   dec   <<   i   <<   endl;      
      //   output   i   preceded   by   its   sign  
   
      cout   <<   showpos   <<   i   <<   endl;  
      //   output   i   in   hexa  
      cout   <<   setbase(16)   <<   i   <<   endl;  
      //   output   i   in   dec   and   pad   to   the   left   with   character  
      //   @   until   a   width   of   20  
      //   if   you   input   45   it   outputs   45@@@@@@@@@@@@@@@@@@    
      cout   <<   setfill('@')   <<   setw(20)   <<   left   <<   dec   <<   i;  
      cout   <<   endl;  
      //   output   the   same   result   as   the   code   just   above  
      //   but   uses   member   functions   rather   than   manipulators  
      cout.fill('@');  
      cout.width(20);  
      cout.setf(ios_base::left,   ios_base::adjustfield);  
   
      cout.setf(ios_base::dec,   ios_base::basefield);  
      cout   <<   i   <<   endl;    
      //   outputs   f   in   scientific   notation   with  
      //   a   precision   of   10   digits  
      cout   <<   scientific   <<   setprecision(10)   <<   f   <<   endl;  
      //   change   the   precision   to   6   digits  
      //   equivalents   to   cout   <<   setprecision(6);  
      cout.precision(6);  
      //   output   f   and   goes   back   to   fixed   notation  
      cout   <<   f   <<   fixed   <<   endl;  
  }  
  //  
  //   cout   example   #2  
  //  
  #include   <iostream>  
  void   main   (   )  
  {  
      using   namespace   std;  
   
      char   p[50];  
      cin.getline(p,50);  
      cout   <<   p;        
  }  
  //  
  //   cout   example   #3  
  //  
  #include   <iostream>  
  #include   <fstream>  
  void   main   (   )  
  {  
      using   namespace   std;  
      //   open   the   file   "file_name.txt"  
      //   for   reading  
      ifstream   in("file_name.txt");  
       
      //   output   the   all   file   to   stdout  
      if   (   in   )    
          cout   <<   in.rdbuf();    
      else  
          {    
              cout   <<   "Error   while   opening   the   file";      
              cout   <<   endl;  
          }  
  }Top

3 楼Maconel(Maconel)回复于 2005-07-01 08:49:11 得分 5

cout   和   cin   是在控制台程序中用的。Top

4 楼smarthui(光君)回复于 2005-07-01 09:27:49 得分 0

跟纯C++里一样吧,应该不会有区别。Top

5 楼wangzg1()回复于 2005-07-01 09:33:38 得分 5

只能用于console吧Top

6 楼XBox360(菜)(鸟)回复于 2005-07-01 09:46:51 得分 0

我好象只见过用于console才这样  
  其他不知道,请大虾们指点!Top

7 楼huabihan(心灵waiting)回复于 2005-07-01 11:48:24 得分 5

应该是只能用在控制台的.Top

8 楼sunliwen780502(孙立文)回复于 2005-07-01 16:10:33 得分 5

只能用在Console程序中。Top

9 楼kkklmn(小虫)回复于 2005-07-03 21:07:19 得分 0

那什么叫做控制台程序呢?我是菜鸟:)Top

相关问题

  • cout输出!
  • C++新手问题,有关cout/cin的输出问题
  • 简单的输入输出问题(cin cout)
  • cout输出什么?
  • cout输出问题
  • cin, cout
  • cout怎么输出char?
  • cout<<"??="<<endl; 的输出怎么会是#
  • 如何用cout输出字符数组?
  • 奇怪,cout不能输出string

关键词

  • cin
  • cout
  • float
  • output
  • using namespace std
  • txt
  • integer
  • reading
  • void main
  • include

得分解答快速导航

  • 帖主:kkklmn
  • Maconel
  • wangzg1
  • huabihan
  • sunliwen780502

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo