943,917 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1218
  • C RSS
Dec 7th, 2005
0

check out this code

Expand Post »
greetings folks,


#include<stdio.h>
#define T t
void main()
{
char T = 'T';
printf("\n%c\t%c\n",T,t);
}

just check what is the output of this program
and puhleease tell me reason whyit happens so??
:rolleyes:
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
akki_freak is offline Offline
12 posts
since Nov 2005
Dec 7th, 2005
0

Re: check out this code

Quote originally posted by akki_freak ...
greetings folks,


#include<stdio.h>
#define T t
void main()
{
char T = 'T';
printf("\n%c\t%c\n",T,t);
}

just check what is the output of this program
and puhleease tell me reason whyit happens so??
:rolleyes:
compile and run that program, then you will see for yourself what the output is. Why does it happen? Because T and t are both the same thing. The #define statement at the top of the program tells the compiler that T is just another name for t.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Algorithms checking
Next Thread in C Forum Timeline: Declarator or Identifier Error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC