<p>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.</p>

<p>For example, in C and C++ you could type:</p>

<pre><code>#include &lt;string&gt;
</code></pre>

<p>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.</p>

<p>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.</p>

CC BY-SA 4.0
2018-10-26T20:18:31.747Z
2018-10-26T20:18:31.747Z
RoboticForest
<p>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.</p>

CC BY-SA 4.0
2018-10-27T02:26:49.017Z
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.
CC BY-SA 4.0
2018-10-27T03:37:17.417Z
Yes I got the answer actually am confused or want to clear about topic.
Iram Shah
<functional-programming><programming-paradigms><programming-environment>
What are Macros in programming language am little bit confuse . why we use them for which perpose?
# What are Macros in programming language am little bit confuse . why we use them for which perpose?

(Asked by: username_0 on 2018-10-26)

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.

**Tags:** functional-programming, programming-paradigms, programming-environment

> **Comments:**
> **username_1**: 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.  
> **username_0**: Yes I got the answer actually am confused or want to clear about topic.  

---

## 1 answers

### Answer by username_2 on 2018-10-26. Score: 3 | Accepted answer

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 

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.


---

