逛奔的蜗牛

我不聪明,但我会很努力

   ::  :: 新随笔 ::  ::  :: 管理 ::
#include <iostream>
#include 
<stack>
#include 
<fstream>
#include 
<cstdio>

int main() {
        FILE 
*fp = fopen("main.cpp""r");
        
if (!fp) {
                std::cerr 
<< "Error" << std::endl;
                
return 1;
        }
        
        
// Google
        char ch, nextCh; // Google
        while ((ch = fgetc(fp)) != EOF) {
                
if ('/' == ch) {
                        nextCh 
= fgetc(fp);
                        
                        
if ('/' == nextCh) {
                                
while (((ch = fgetc(fp)) != EOF)) {
                                        
if ('\n' == ch) {
                                                std::cout 
<< std::endl;
                                                
break;
                                        }
                                }
                        } 
else if ('*' == nextCh) {
                                
while ((ch = fgetc(fp)) != EOF) {
                                        
if ('*' == ch) {
                                                nextCh 
= fgetc(fp);
                                                
if (nextCh == EOF || '/'
                                                                
== nextCh) {
                                                        
break;
                                                }
                                        }
                                }
                        } 
else {
                                std::cout 
<< /**Commentar*/ch << nextCh;
                        }
                        
/**Commentar*/
                        
/**Com
                         * mentar
*/
                } 
else {
                        std::cout 
<< ch;
                }
        }
        
/***********\\\/////// */
        
///**//

        
return 0;
}

posted on 2008-04-12 05:12 逛奔的蜗牛 阅读(499) 评论(0)  编辑 收藏 引用 所属分类: C/C++

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理