<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>function | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/function/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Mon, 29 Aug 2011 09:39:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>Program to delete n Characters from a given position in a given string using functions</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/string/program-delete-characters-position-string-functions/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/string/program-delete-characters-position-string-functions/#comments</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 09:39:37 +0000</pubDate>
				<category><![CDATA[String Programs]]></category>
		<category><![CDATA[delete characters]]></category>
		<category><![CDATA[string programs]]></category>
		<category><![CDATA[function]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1750</guid>

					<description><![CDATA[<p>This C program uses function delchar to delete n characters from a given position in a given string. #include "stdio.h" #include "conio.h" #include "string.h" void delchar(char *x,int a, int b); void main() { char string[10]; int n,pos,p; clrscr(); puts("Enter the string"); gets(string); printf("Enter the position from where to delete"); scanf("%d",&#38;pos); printf("Enter the number of characters</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/string/program-delete-characters-position-string-functions/">Program to delete n Characters from a given position in a given string using functions</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>This C program uses function delchar to delete n characters from a given position in a given string.</p>
<pre lang="c" escaped="true" line="1">
#include "stdio.h"
#include "conio.h"
#include "string.h"

void delchar(char *x,int a, int b);

void main()
{
     char string[10];
     int n,pos,p;
     clrscr();

     puts("Enter the string");
     gets(string);
     printf("Enter the position from where to delete");
     scanf("%d",&amp;pos);
     printf("Enter the number of characters to be deleted");
     scanf("%d",&amp;n);
     delchar(string, n,pos);
     getch();
}

// Function to delete n characters
void delchar(char *x,int a, int b)
{
  if ((a+b-1) &lt;= strlen(x))
  {
    strcpy(&amp;x[b-1],&amp;x[a+b-1]);
    puts(x);
    }
}</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/string/program-delete-characters-position-string-functions/">Program to delete n Characters from a given position in a given string using functions</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/string/program-delete-characters-position-string-functions/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>What is the difference between macro and function?</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-faq/difference-macro-function/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-faq/difference-macro-function/#comments</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Fri, 19 Aug 2011 10:02:40 +0000</pubDate>
				<category><![CDATA[C Questions & Answers]]></category>
		<category><![CDATA[difference]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[function]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1652</guid>

					<description><![CDATA[<p>Here are the differences between macro and function, 1.Macro consumes less time: When a function is called, arguments have to be passed to it, those arguments are accepted by corresponding dummy variables in the function. Then they are processed, and finally the function returns a value that is assigned to a variable (except for a</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/difference-macro-function/">What is the difference between macro and function?</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Here are the differences between macro and function,<br />
<strong></strong></p>
<p><strong>1.Macro consumes less time:</strong><br />
<span> </span>When a function is called, arguments have to be passed to it, those arguments are accepted by corresponding dummy variables in the function. Then they are processed, and finally the function returns a value that is assigned to a variable (except for a void function). If a function is invoked number of times, the times add up, and compilation is delayed. On the other hand, the macro expansion had already taken place and replaced each occurrence of the macro in the source code before the source code starts compiling, so it requires no additional time to execute.<br />
<strong></strong></p>
<p><strong>2. Function consumes less memory</strong>:<br />
<span> </span>Prior to compilation, all the macro-presences are replaced by their corresponding macro expansions, which consumes considerable memory. On the other hand, even if a function is invoked 100 times, it still occupies the same space. Hence function consumes less memory.<br />
<strong></strong></p>
<p><strong>Example for Macro:</strong><br />
The following line defines the macro SUM, having two parameters a and b and the replacement tokens (a + b):</p>
<p>#define SUM(a,b) (a + b)</p>
<p>This definition would cause the preprocessor to change the following statements (if the statements appear after the previous definition):<br />
c = SUM(x,y);<br />
c = d * SUM(x,y);<br />
In the output of the preprocessor, these statements would appear as:<br />
c = (x + y);<br />
c = d * (x + y);<br />
<strong></strong></p>
<p><strong>Example for function:</strong><br />
In calling program function call would appear as,</p>
<p>c=SUM(x,y);</p>
<p>Where sum is the name of the function. And x, y are the arguments passed from calling program to called program.<br />
This statement will invoke the following function SUM. Hence x, y are copied to dummy variables a and b. And then function computes the sum and stores the value in c, which will be returned back to the calling program.</p>
<p>int sum(int a, int b)<br />
{<br />
int c;<br />
c=a+b;<br />
return c;<br />
}</p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/difference-macro-function/">What is the difference between macro and function?</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c-faq/difference-macro-function/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>What is the difference between new and malloc?</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-faq/difference-malloc/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-faq/difference-malloc/#comments</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Fri, 19 Aug 2011 09:29:06 +0000</pubDate>
				<category><![CDATA[C Questions & Answers]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[malloc]]></category>
		<category><![CDATA[new]]></category>
		<category><![CDATA[operator ++]]></category>
		<category><![CDATA[destructor]]></category>
		<category><![CDATA[constructor]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1648</guid>

					<description><![CDATA[<p>Here are the differences between new and malloc, Operator new constructs an object (calls constructor of object), malloc does not. Hence new invokes the constructor (and delete invokes the destructor)This is the most important difference. operator new is an operator, malloc is a function. operator new can be overloaded, malloc cannot be overloaded. operator new</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/difference-malloc/">What is the difference between new and malloc?</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Here are the differences between new and malloc,</p>
<ol>
<li>Operator new constructs an object (calls constructor of object), malloc does not. Hence new invokes the constructor (and delete invokes the destructor)This is the most important difference.</li>
<li>operator new is an operator, malloc is a function.</li>
<li>operator new can be overloaded, malloc cannot be overloaded.</li>
<li>operator new throws an exception if there is not enough memory, malloc returns a NULL.</li>
<li>operator new[] requires you to specify the number of objects to allocate, malloc requires you to specify the total number of bytes to allocate.</li>
<li>operator new/new[] must be matched with operator delete/delete[] to deallocate memory, malloc() must be matched with free() to deallocate memory.</li>
</ol>
<p><strong>Syntax of new is:</strong><br />
p_var = new type name;<br />
Where p_var is a previously declared pointer of type typename. And typename can be any basic data type.</p>
<p><strong>Example:</strong><br />
int  *p;<br />
p = new int;<br />
It allocates memory space for an integer variable.</p>
<p><strong>Syntax of malloc is:</strong><br />
p_var = (typename *)malloc(sizeof(typename));<br />
Where p_var is a previously declared pointer of type typename. And typename can be any basic data type.<br />
<strong></strong></p>
<p><strong>Example:<br />
</strong>int *p;<br />
p = (int *)malloc(sizeof(int));<br />
This statement &#8220;allocates&#8221; or &#8220;reserves&#8221; a block of memory for an integer from the heap. Then it places the address of the reserved block into the pointer variable (p, in this case).</p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/difference-malloc/">What is the difference between new and malloc?</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c-faq/difference-malloc/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
