C Programming - Typedef - Discussion
Discussion Forum : Typedef - Yes / No Questions (Q.No. 4)
4.
typedef's have the advantage that they obey scope rules, that is they can be declared local to a function or a block whereas #define's always have a global effect.
Discussion:
4 comments Page 1 of 1.
Karthik said:
1 decade ago
For eg.,
{
typedef char c;
c c1;//c is char
{
typedef int c;
c d1;//c is int
}
}
But #define always has global scope till the end of the file.
{
typedef char c;
c c1;//c is char
{
typedef int c;
c d1;//c is int
}
}
But #define always has global scope till the end of the file.
Swathi said:
1 decade ago
#define function used in globally. We can access that data in the program any where.
Yash said:
8 years ago
Yes, right, @Karthik.
Lovely said:
1 decade ago
Yes it is possible.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers