| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 606 人关注过本帖
标题:另開一貼發圖
只看楼主 加入收藏
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
结帖率:100%
收藏
 问题点数:0 回复次数:4 
另開一貼發圖
#include  <afxcoll.h>    //Provides Access to MFC functions
class CDrawBox : public CObject
{
public :
 // Draws the box.
 void DoDraw(char * string);
};
void CDrawBox :: DoDraw(char * cValue)
{
 int      iCount;    //Loop counter
 int      iSpace;    //Amount of spaces to add for string.
 // Draw the top of the box
 fprintf(stdout,"\311");
 for (iCount = 1;  iCount <= 78 ; iCount ++)
 {     
  fprintf(stdout,"\315");
 }
 fprintf(stdout,"\273");
 // Figure out the center of the string, then display it with the box sides.
 iSpace = (80 - strlen(cValue)) / 2;
 fprintf(stdout,"\272");
 for (iCount = 1;  iCount <=  iSpace ; iCount ++)
 {     
  fprintf(stdout,"  ");
 }
 fprintf(stdout, "%s", cValue);
 // Compensate for odd sized strings, then complete the side.
 if ((strlen(cValue) % 2) == 1)
 {     
  iSpace--;
 }
 for (iCount = 1;  iCount <=  iSpace ; iCount ++)
 {     
  fprintf(stdout, "  ");
 }
 fprintf(stdout,"\272");
 // Draw the bottom of the box
 fprintf(stdout, "\310");
 for (iCount = 1;  iCount <= 78 ; iCount ++)
 {     
  fprintf(stdout, "\315");
 }
 fprintf(stdout, "\274\n");
}
int main(int  argc, char **  argv)
{
 char *     cName;    // Name of person typed at command line.
 char *     cLocale;   // Program execution location.
 CTime     oMyTime;  // A time object.
 CString     cDate;    // String used to hold time and date.
 CDrawBox  oMyDraw;  // Special text display.
 // See if we have enough command line arguments.
 if ( argc != 2)
 {     
  fprintf(stderr, "Type the program name followed by your name.\n");     
  return 1;
 }
 // Get the command line arguments
 cLocale = argv[0];
 cName = argv[1];
 // Get the current time and put it in a string.
 oMyTime = CTime::GetCurrentTime();
 cDate = oMyTime.Format( "%A, %B %d,%Y" );
 //Display everything we've collected.
 fprintf(stdout, "Hello %s\n\n", cName);
 fprintf(stdout, "Program is executing from: \n%s\n\n", cLocale);
 fprintf(stdout, "The date is: %s\n", cDate);
 // Use our class to draw a box around some text.
 oMyDraw.DoDraw("It's a box!");
 return 0;
}

程序應該出現的圖片
图片附件: 游客没有浏览图片的权限,请 登录注册
2007-12-03 10:45
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 
你用到了命令行参数,那么就要在命令模式下输入你的参数。
直接在编译器里运行的话,没结果的。

Fight  to win  or  die...
2007-12-03 15:55
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
收藏
得分:0 
怎样做?请版主说明白点,我才学C++

汽车尾气检测网络系统QQ:357766186__MSN:MSNTHW19850316@
2007-12-03 16:01
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 
你在WINDOWS 下运行命令行提示符,然后找到你编译出来的exe文件,键入文件名,和参数,参数用空格格开,具体每个参数的意思要看你代码里怎么用的。

你可以去搜索下“c++ 命令行参数”。

Fight  to win  or  die...
2007-12-03 16:24
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
收藏
得分:0 
谢谢版主

汽车尾气检测网络系统QQ:357766186__MSN:MSNTHW19850316@
2007-12-05 10:23
快速回复:另開一貼發圖
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025196 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved