网站建设
  简约型网页设计套餐998
  实惠型网站建设套餐2580
  综合型网站制作套餐4980
  网站改版与网站维护
  行业网站建设方案
  大型网站建设解决方案
  企业网站建设流程
  帝网科技网站设计与网站制作
建站FAQ
·网站空间问题解答
·企业邮箱问题解答
 
酷站欣赏
·房产酷站(379)
·综合门户(8 9)
·建筑装饰(603)
·手机通讯(354)
·生活购物(376)
·医疗保健(199)
·文化摄影(602)
·休闲体育(399)
>>更多酷站欣赏
网站优化
·Google(谷歌)优化   ·百度(BaiDu)优化
·雅虎(Yahoo)优化    ·Alexa排名优化   
·Google AdSense   ·DMOZ目录提交  
建站知识
·网站建设知识·网站名词解释·网站运营知识
·网络营销知识·搜索引擎知识·实用技术文摘
网站推广
百度网站推广 google网站推广
搜狐网站推广 网易网站推广
新浪网站推广   雅虎网站推广
  您当前位置: 当前位置:帝网科技 >> web开发 >> .NET专栏 >> 浏览文章
 
 
.net开发:如何为程式码加上行号
作者:袁袁整理 来源:帝网科技 日期:2008年11月17日 点击数:



Abstract

若需要将程式码放进word交报告或做文件时,或许我们会想将程式码加上行号方便讲解,如同博客园显示程式码那样,我们该如何做呢?

Introduction

使用环境:Visual C++ 9.0 / Visual Studio 2008

一段C++的小程式,可以帮程式码加上行号后输出。
   以下为引用的内容:
      map_code_line.cpp / C++
         /*
         (C) OOMusou 2008 http://oomusou.cnblogs.com

         Filename    : map_code_line.cpp
         Compiler    : Visual C++ 9.0 / Visual Studio 2008
         Description : Demo how to add line number for code
         Release     : 07/18/2008 1.0
         */
         #include
         #include
         #include
         #include
         #include
         using namespace std;
         ifstream infile("map_code_line.cpp");
         ofstream outfile("map_code_line_r.cpp");
         struct print_map {
           void operator() (pair p) {
             cout    << p.first << " " << p.second << endl;
             outfile << p.first << " " << p.second << endl;
           }
         };
         int main() {
           map lines;
           string line;
           int line_num = 1;
           while(getline(infile, line))
           lines[line_num++] = line;
           infile.close();
           for_each(lines.begin(), lines.end(), print_map());
           outfile.close();
         }
 
 
执行结果

以下为引用的内容:
         /*
         (C) OOMusou 2008 http://oomusou.cnblogs.com

         Filename    : map_code_line.cpp
         Compiler    : Visual C++ 9.0 / Visual Studio 2008
         Description : Demo how to add line number for code
         Release     : 07/18/2008 1.0
         */
         #include
         #include
         #include
         #include
         #include
         using namespace std;
         ifstream infile("map_code_line.cpp");
         ofstream outfile("map_code_line_r.cpp");
         struct print_map {
           void operator() (pair p) {
             cout    << p.first << " " << p.second << endl;
             outfile << p.first << " " << p.second << endl;

  相关文章
 
·ASP.NET使用log4Net日志组件教程(日志
·ASP.NET MVC 框架
·C#实现的BinaryTree
·WebForms使用System.Web.Routing
·ASP.NET获取远程网页下载到本地文件
·一个“简单”的ASP.NET的服务器控件
·ASP.net与PHP两大网站开发架构优势对比
·教你七招提高.NET网站性能
·ASP.NET未来:简化开发 HTML5性能提升
·ASP.NET实现类似Excel的数据透视表
·FileUpload上传多文件出现错误的解决方
·.NET从优酷专辑中采集所有视频及信息(
·ASP.NET 4中的SEO改进
·详解Asp.net MVC DropDownLists
·提高ASP.NET应用程序性能的几招方法
·asp.net实现51job地区选择效果
·ASP.NET中创建GeoRSS订阅源
·ASP.NET 4.0开发更加简便
·ASP.NET页面间数据传递的方法
·ASP.NET的SEO:使用.ashx文件——排除
 
 

公司环境 | 合作伙伴 | 人才招聘 | 付款方式 | 关于我们

地址:广州市天河区中山大道中120号D805 电话:020-82529556 传真:020-82529556
广州帝网网络科技有限公司 版权所有 粤ICP备08119341号