需要帮助计算预处理程序指令之间的行数 [英] Help needed to count lines between preprocessor directives

查看:69
本文介绍了需要帮助计算预处理程序指令之间的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想要一个程序。它应该是一个命令行。你可以输入一个文件夹(最好)或文件的

路径......它应该计算一个no。

编译器指令之间的行,

ifdef win32和#endif.can u请帮助我...

Hi,
I want a program. It should be a command line one. you can input the
path of a folder(preferably) or a file...it should count the no. of
lines between the compiler directives,
ifdef win32 and # endif.can u pls help me out...

推荐答案

Nalla写道:

我想要一个程序。它应该是一个命令行。你可以输入一个文件夹的路径(最好)或一个文件...它应该算上
没有。编译器指令之间的行,
ifdef win32和#endif.can u请帮助我...
Hi,
I want a program. It should be a command line one. you can input
the path of a folder(preferably) or a file...it should count the
no. of lines between the compiler directives,
ifdef win32 and # endif.can u pls help me out...




很高兴。


编写一个接受命令行参数的程序。决定

如何处理你的

赋值没有意义的输入,并编写代码来做到这一点。

对于有效输入,我认为,这将是

包含至少一个编译器指令的文件的名称,打开该文件。如果它正确打开

,一次读取一行并确定该行
是否包含编译器指令。如果是,请从

下一行开始计算。当你到达下一个编译器指令时,发出一条消息

,告诉你你已计算了多少行,并准备再次开始计算
。继续,直到你用完线。决定你如何处理最后一行的报告(如果最后一个编译器指令后面有任何
)。关闭文件。发出你认为合适的任何结论

消息。


我可以证明我是在运行Windows 2000的机器上写的。

希望有所帮助。


这里有一些代码(未经测试):

#include< stdlib.h>


int main(int argc,char * argv [])

{


/ *做我说过的话* /


返回EXIT_SUCCESS;

}


-

rzed



Glad to.

Write a program that accepts arguments from the command line. Decide
what to do with input that doesn''t make sense in terms of your
assignment, and write the code to do that.

For valid input, which will, I assume, be the name of a file that
contains at least one compiler directive, open the file. If it opens
correctly, read it one line at a time and determine whether the line
contains a compiler directive. If it does, begin counting with the
next line. When you reach the next compiler directive, emit a message
that tells you how many lines you have counted, and prepare to start
counting again. Continue until you run out of lines. Decide how you
will handle reporting on the last set of lines (if there are any after
the last compiler directive). Close the file. Emit any concluding
messages you think appropriate.

I can attest that I am writing this on a machine running Windows 2000.

Hope that helps.

Here''s some code (untested):
#include <stdlib.h>

int main( int argc, char * argv[] )
{

/* do the stuff I talked about */

return EXIT_SUCCESS;
}

--
rzed


Nalla< na ********** @ fastmail.fm>写道:
Nalla <na**********@fastmail.fm> wrote:
我想要一个程序。它应该是一个命令行。你可以输入文件夹的路径(最好是)或文件......它应该算一下。
编译器指令之间的界限,
ifdef win32和#endif.can你帮帮我...
I want a program. It should be a command line one. you can input the
path of a folder(preferably) or a file...it should count the no. of
lines between the compiler directives,
ifdef win32 and # endif.can u pls help me out...




对不起,但是clc既不是alt.source.wanted也不是你的问题

与C有关。


< OT>

自今天我感觉很好,这是一个(完全未经测试!)

Perl脚本(我不知道你的意思是文件夹的路径因为

a文件夹中很少有行。甚至更少的编译器指令。

我也常常试图避免在C

中做这样的事情因为我太懒或者有更好的事情要做):


#!/ usr / bin / perl -w


使用严格;


my



Sorry, but clc is neither alt.source.wanted nor has your question
anything to do with C.

<OT>
Since I feel like being nice today here''s an (completely untested!)
Perl script (I don''t know what you mean by "path of folder" because
a folder rarely has lines in it. and even less compiler directives.
I also would usually try to avoid doing something like this in C
because I am too lazy or got better things to do):

#!/usr/bin/perl -w

use strict;

my


f;

my(
f;
my (


这篇关于需要帮助计算预处理程序指令之间的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆