[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: preprocessor directives?



hi,
   when cpp ( pre-processor ) runs it converts all $define as said.
	so after cpp code does not have any #defines and all it's corresponding
 values are replaced with defined values.

	out put of file only preprocessed ( gcc -E ....) ( note this is out got
on my m/c)
--------------------------------------------
# 1 "1.c" 2

main()
{
int first=0,second=1;

printf("%d:%d\n",first,second);


printf("%d:%d\n",first  ,second  );
exit(0);
}
-------------------------------------------
	now i think u can see , why result came as it is given.
		0:1
		0:1
since that is what code does...
hth
bye
ketan

	if i missed anything... let me know.

honne gowda gowda wrote:
> 
> hi,
> 
> can somebody explain the following piece of code:
> 
> #include<stdio.h>
> main()
> {
> int first=0,second=1;
> 
> printf("%d:%d\n",first,second);
> #define first second
> #define second first
> printf("%d:%d\n",first,second);
> exit(0);
> }
> 
> thanx in advance