Re: Using define with variable values
- From: roberson@xxxxxxxxxxxxxxxxxx (Walter Roberson)
- Date: 30 Apr 2005 04:54:15 GMT
In article <1114835021.236146.283510@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
<msigwald@xxxxxxxxx> wrote:
>The following line of code works, however, since my professor is a real
>purist of c, I would like to know if this code is valid (is it good
>code or a piece of crap?):
>#define DMP_FILE argv[argc-1]
It is completely legitimate C. There are two kinds of #define,
one "object like" and the other "function like". Either one is
permitted to include a wide range of syntax, not limited to
constants or variables or simple expressions. It is valid C to
use something like #define BEGIN {
or to otherwise appear to distort the syntax of C.
Whether it is good -style- is a different question.
>This would be use to do something like this:
>void main(int argc,char *argv[])
>{
> FILE *p2file=fopen(DMP_FILE,"w");
>}
>
What happens if no arguments were passed? Are you going to
overwrite the binary executable itself?
--
Warning: potentially contains traces of nuts.
.
- References:
- Using define with variable values
- From: msigwald
- Using define with variable values
- Prev by Date: Re: Binary Arithmetics
- Next by Date: Re: How to get file size?
- Previous by thread: Using define with variable values
- Next by thread: Re: Using define with variable values
- Index(es):
Relevant Pages
|