# What are Macros in programming language am little bit confuse . why we use them for which perpose? [closed]

What are macros in programming language ? And we use these macros and for which perpose.I saw a YouTube video and also read from a link but am cofused about why we use them.

## closed as off-topic by Gypsy Spellweaver, Buffy, Ben I.♦Oct 27 '18 at 2:25

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question does not appear to be about Computer Science education, within the scope defined in the help center." – Gypsy Spellweaver, Buffy, Ben I.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Hi, IramShah, welcome to CSEd! I'm afraid that this question was closed because it's off-topic for our site, which focuses on how to teach effectively within a computer science classroom. I see that you already received a pretty good answer as well, so hopefully you have gotten the help that you need. – Ben I. Oct 27 '18 at 2:26
• Yes I got the answer actually am confused or want to clear about topic. – Iram Shah Oct 27 '18 at 3:37

What macro are, and how the work, changes from language to language. That said, they are very generally a way to reuse code, often by doing searches and replacements within the code before it gets compiled or interpreted.

For example, in C and C++ you could type:

#include <string>


which is a macro asking for the entire contents of the file "string" to be placed where the #include instruction line is. That makes the code in that file available to the code in the file the programmer is writing, all with only one instruction.

Sometimes macros can also be used to make code easier to read or understand by either changing the name of something or by changing how certain code looks in specific situations. Macros can also be used to ensure code for some regularly occurring or complex task gets written properly.