check out this code

Reply

Join Date: Nov 2005
Posts: 12
Reputation: akki_freak is an unknown quantity at this point 
Solved Threads: 0
akki_freak akki_freak is offline Offline
Newbie Poster

check out this code

 
0
  #1
Dec 7th, 2005
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:
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 16,612
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1614
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: check out this code

 
0
  #2
Dec 7th, 2005
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1163 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC