Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Whats the difference between using a typedef or a #define for a user-defined type?

0
Posted

Whats the difference between using a typedef or a #define for a user-defined type?

0

See question 1.13. comp.lang.c FAQ list · Question 10.5b Q: What’s the difference between const MAXSIZE = 100; and #define MAXSIZE 100 A: A preprocessor #define gives you a true compile-time constant. In C, const gives you a run-time object which you’re not supposed to try to modify; “const” really means “readonly”. See also the question 11.8. (But in C++, const is closer to #define.) Additional links: longer explanation comp.lang.c FAQ list · Question 10.6 Q: I’m splitting up a program into multiple source files for the first time, and I’m wondering what to put in .c files and what to put in .h files. (What does “.h” mean, anyway?) A: As a general rule, you should put these things in header (.h) files: macro definitions (preprocessor #defines) structure, union, and enumeration declarations typedef declarations external function declarations (see also question 1.11) global variable declarations It’s especially important to put a declaration or definition in a header file when it

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123