By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,346 Members | 2,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,346 IT Pros & Developers. It's quick & easy.

how can count how many variables from file in c code and also find how many function

P: 2
how can count how many variables from file in c code and how many
function in c file please give answer write a c/c++ code
thanks
Feb 23 '18 #1

✓ answered by weaknessforcats

Are you trying to write a compiler? This is not a simple problem. If this is a homework problem, do you have a particular C file you are supposed to be using?

Share this Question
Share on Google+
3 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
Are you trying to write a compiler? This is not a simple problem. If this is a homework problem, do you have a particular C file you are supposed to be using?
Feb 23 '18 #2

P: 2
no , i read a file than count how many function in there but i could not <C file>
Feb 23 '18 #3

Expert 100+
P: 2,400
It is easier to parse a compiled object file than a C source file.
It is even easier to use a language like Perl to process the output of an object file parsing tool such as nm.

Is a list of symbols sufficient or do you need to distinguish function and variable names?
Is a list of global names sufficient or do you need to also get the local (static) names?

If you must parse a source file, are you allowed to enforce a no-typedefs rule? Typedefs complicate the source-parsing logic.

Can you parse the output of the C preprocessor or are you required to recognize and deal with macro definitions, macro references, conditional compilation, etc?
Feb 27 '18 #4

Post your reply

Sign in to post your reply or Sign up for a free account.