<divclass="center"><iframescrolling="no"frameborder="0"src="../../d8/dcc/min__printf_8h__incl.svg"width="262"height="124"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<divclass="center"><iframescrolling="no"frameborder="0"src="../../de/d50/min__printf_8h__dep__incl.svg"width="150"height="139"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<trclass="memdesc:"><tdclass="mdescLeft"> </td><tdclass="mdescRight">struct used to store character in certain times <ahref="../../dd/da2/structbuffer.html#details">More...</a><br/></td></tr>
<trclass="memdesc:ab47a4bec9213d96e1dba5171e5db0e25"><tdclass="mdescLeft"> </td><tdclass="mdescRight">for <code>malloc</code> and <code>free</code> functions for <code>write</code> function for <code>va_start</code> and <code>va_arg</code> functions <br/></td></tr>
<trclass="memdesc:abf0876f583782407c9e15c60158eec52"><tdclass="mdescLeft"> </td><tdclass="mdescRight">struct used to store character in certain times <br/></td></tr>
<trclass="memdesc:ad4908ab912d8dc481225e33ca3285c21"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Checks if a character is a number. <ahref="../../d9/deb/min__printf_8h.html#ad4908ab912d8dc481225e33ca3285c21">More...</a><br/></td></tr>
<trclass="memdesc:a409d428c337bf5476567a228274f49f1"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns specific required next character. <ahref="../../d9/deb/min__printf_8h.html#a409d428c337bf5476567a228274f49f1">More...</a><br/></td></tr>
<trclass="memdesc:aa8a17b7d234a2fb2174da02074a14055"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Stores character to the <code>buffer->buffr_char</code><ahref="../../d9/deb/min__printf_8h.html#aa8a17b7d234a2fb2174da02074a14055">More...</a><br/></td></tr>
<trclass="memdesc:aefb40d94d5d9fa2a28bc64755dde096f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Calculates the number of digits in a number. <ahref="../../d9/deb/min__printf_8h.html#aefb40d94d5d9fa2a28bc64755dde096f">More...</a><br/></td></tr>
<trclass="memdesc:ad2f9a02e1d69f58e2fb1248f49d09f4b"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Prints one character on screen. <ahref="../../d9/deb/min__printf_8h.html#ad2f9a02e1d69f58e2fb1248f49d09f4b">More...</a><br/></td></tr>
<trclass="memdesc:a8d68ec60643cacdb402176549565754e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Reverses a string using <ahref="https://www.geeksforgeeks.org/program-reverse-array-using-pointers/?ref=rp"target="_blank">two pointer algorithm</a><ahref="../../d9/deb/min__printf_8h.html#a8d68ec60643cacdb402176549565754e">More...</a><br/></td></tr>
<trclass="memitem:a0a848efdf2ee124bba62e056eb9ab824"><tdclass="memItemLeft"align="right"valign="top">void </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="../../d9/deb/min__printf_8h.html#a0a848efdf2ee124bba62e056eb9ab824">print_int_value</a> (int n, int width, int precision)</td></tr>
<trclass="memitem:a4d63203d920bebd6a96f5f4aeccb21e5"><tdclass="memItemLeft"align="right"valign="top">void </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="../../d9/deb/min__printf_8h.html#a4d63203d920bebd6a96f5f4aeccb21e5">print_double_value</a> (double dval, int width, int precision)</td></tr>
<trclass="memdesc:a4d63203d920bebd6a96f5f4aeccb21e5"><tdclass="mdescLeft"> </td><tdclass="mdescRight">The algorithm here is also the same as the <code>print_int_value</code> function. <ahref="../../d9/deb/min__printf_8h.html#a4d63203d920bebd6a96f5f4aeccb21e5">More...</a><br/></td></tr>
<trclass="memitem:af569209570eca8bc6770fb7d9dc873e6"><tdclass="memItemLeft"align="right"valign="top">void </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="../../d9/deb/min__printf_8h.html#af569209570eca8bc6770fb7d9dc873e6">print_string</a> (char *p, int width, int precision)</td></tr>
<trclass="memitem:aa61e2407aab2c75e9837c77cab937d03"><tdclass="memItemLeft"align="right"valign="top">char * </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="../../d9/deb/min__printf_8h.html#aa61e2407aab2c75e9837c77cab937d03">get_width_and_precision</a> (char *p, <aclass="el"href="../../d9/deb/min__printf_8h.html#abf0876f583782407c9e15c60158eec52">Buffer</a> *<aclass="el"href="../../dd/da2/structbuffer.html">buffer</a>, int *width, int *precision)</td></tr>
<trclass="memdesc:aa61e2407aab2c75e9837c77cab937d03"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Takes width and precision specified from the format of the string. <ahref="../../d9/deb/min__printf_8h.html#aa61e2407aab2c75e9837c77cab937d03">More...</a><br/></td></tr>
<trclass="memdesc:a33e08c05f8c656a0fee465c2e8d2ecf9"><tdclass="mdescLeft"> </td><tdclass="mdescRight">min_printf is the function same as printf <ahref="../../d9/deb/min__printf_8h.html#a33e08c05f8c656a0fee465c2e8d2ecf9">More...</a><br/></td></tr>
<divclass="textblock"><p>Implementation of a <ahref="https://www.geeksforgeeks.org/variable-length-argument-c"target="_blank">function</a> similar to <code>printf</code></p>
<p><code>printf</code> statement rewritten (as <code>min_printf</code>) in C without using the <code>stdio.h</code> library Syntax of <code>min_printf</code> is same as <code>printf</code> Currently min_printf handles: Integers, Doubles, floats, characters and strings The format specifiers and escape sequence is the same as for <code>printf</code> User can also specify the width and precision if required, just like in the case of <code>printf</code> How to use it:</p><ul>
<li>First include <aclass="el"href="../../d9/deb/min__printf_8h.html"title="Implementation of a function similar to printf">min_printf.h</a> in your code</li>
<li>Then type <code><aclass="el"href="../../d9/deb/min__printf_8h.html#a33e08c05f8c656a0fee465c2e8d2ecf9"title="min_printf is the function same as printf">min_printf()</a></code>, and pass required parameters to it</li>
<li>As already specified, it's syntax is same as printf <dlclass="section author"><dt>Author</dt><dd><ahref="https://github.com/Jaskarn7"target="_blank">Jaskarn Singh</a></dd></dl>
<tr><tdclass="paramname">p</td><td>pointer to a format string of <code><aclass="el"href="../../d9/deb/min__printf_8h.html#a33e08c05f8c656a0fee465c2e8d2ecf9"title="min_printf is the function same as printf">min_printf()</a></code></td></tr>
<tr><tdclass="paramname">buffer</td><td>struct for checking if buffr_char character is present or not </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>character inside <code>buffer->buffr_char</code>, if <code>buffer->buf_size</code> is one </dd>
<dd>
character at which p is pointing, if <code>buffer->buf_size</code> is zero </dd></dl>
<p>< Since character is used, this sets <code>buffer->buf_size</code> to zero</p>
<divclass="line"><spanclass="lineno"> 73</span><aclass="code hl_struct"href="../../dd/da2/structbuffer.html">buffer</a>->buf_size = 0; <spanclass="comment">///< Since character is used, this sets `buffer->buf_size` to zero</span></div>
<divclass="line"><spanclass="lineno"> 74</span><spanclass="keywordflow">return</span><aclass="code hl_struct"href="../../dd/da2/structbuffer.html">buffer</a>->buffr_char; <spanclass="comment">// Returns character inside buffer->buffr_char</span></div>
<divclass="ttc"id="astructbuffer_html"><divclass="ttname"><ahref="../../dd/da2/structbuffer.html">buffer</a></div><divclass="ttdoc">struct used to store character in certain times</div><divclass="ttdef"><b>Definition:</b> min_printf.h:31</div></div>
<divclass="line"><spanclass="lineno"> 100</span> ++digits; <spanclass="comment">// Since number still contains a digit, so increment digit variable</span></div>
<divclass="line"><spanclass="lineno"> 101</span> n /= 10; <spanclass="comment">// Removes last digit from number</span></div>
<divclass="line"><spanclass="lineno"> 281</span><spanclass="comment">/* Calculates the precision specified.*/</span></div>
<divclass="line"><spanclass="lineno"> 282</span><spanclass="keywordflow">if</span> (*p == <spanclass="charliteral">'.'</span><spanclass="comment">/* Since a precision is always specified after a '.'. */</span>) { </div>
<divclass="line"><spanclass="lineno"> 285</span><aclass="code hl_function"href="../../d9/deb/min__printf_8h.html#aa8a17b7d234a2fb2174da02074a14055">unget_ch</a>(p, <aclass="code hl_struct"href="../../dd/da2/structbuffer.html">buffer</a>); <spanclass="comment">// The non number will be stored in `buffer->buffr`</span></div>
<divclass="ttc"id="amin__printf_8h_html_aa8a17b7d234a2fb2174da02074a14055"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#aa8a17b7d234a2fb2174da02074a14055">unget_ch</a></div><divclass="ttdeci">void unget_ch(char *c, Buffer *buffer)</div><divclass="ttdoc">Stores character to the buffer->buffr_char</div><divclass="ttdef"><b>Definition:</b> min_printf.h:84</div></div>
<divclass="ttc"id="amin__printf_8h_html_ad4908ab912d8dc481225e33ca3285c21"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#ad4908ab912d8dc481225e33ca3285c21">is_number</a></div><divclass="ttdeci">int is_number(char *c)</div><divclass="ttdoc">Checks if a character is a number.</div><divclass="ttdef"><b>Definition:</b> min_printf.h:58</div></div>
<divclass="center"><iframescrolling="no"frameborder="0"src="../../d9/deb/min__printf_8h_aa61e2407aab2c75e9837c77cab937d03_cgraph.svg"width="307"height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<divclass="line"><spanclass="lineno"> 297</span> va_list ap; <spanclass="comment">// Points to each unnamed arg in turn</span></div>
<divclass="line"><spanclass="lineno"> 298</span><spanclass="keywordtype">char</span> *p, *sval; <spanclass="comment">// p will be used to point to fmt and sval will store string value</span></div>
<divclass="line"><spanclass="lineno"> 299</span><spanclass="keywordtype">char</span> cval; <spanclass="comment">// Stores character value</span></div>
<divclass="line"><spanclass="lineno"> 300</span><spanclass="keywordtype">int</span> ival; <spanclass="comment">// For integer values</span></div>
<divclass="line"><spanclass="lineno"> 301</span><spanclass="keywordtype">double</span> dval; <spanclass="comment">// For double or float values</span></div>
<divclass="line"><spanclass="lineno"> 302</span> va_start(ap, fmt); <spanclass="comment">// Makes ap points to first unnames argument</span></div>
<divclass="line"><spanclass="lineno"> 306</span><aclass="code hl_struct"href="../../dd/da2/structbuffer.html">buffer</a>->buf_size = 0; <spanclass="comment">// Initially set buffer size to zero as no character is inserted</span></div>
<divclass="ttc"id="amalloc__dbg_8h_html_a725f50ecaf1959d96de79b36b4788fee"><divclass="ttname"><ahref="../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee">malloc</a></div><divclass="ttdeci">#define malloc(bytes)</div><divclass="ttdoc">This macro replace the standard malloc function with malloc_dbg.</div><divclass="ttdef"><b>Definition:</b> malloc_dbg.h:18</div></div>
<divclass="ttc"id="amin__printf_8h_html_a0a848efdf2ee124bba62e056eb9ab824"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#a0a848efdf2ee124bba62e056eb9ab824">print_int_value</a></div><divclass="ttdeci">void print_int_value(int n, int width, int precision)</div><divclass="ttdef"><b>Definition:</b> min_printf.h:154</div></div>
<divclass="ttc"id="amin__printf_8h_html_a409d428c337bf5476567a228274f49f1"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#a409d428c337bf5476567a228274f49f1">get_ch</a></div><divclass="ttdeci">char get_ch(char *p, Buffer *buffer)</div><divclass="ttdoc">Returns specific required next character.</div><divclass="ttdef"><b>Definition:</b> min_printf.h:70</div></div>
<divclass="ttc"id="amin__printf_8h_html_a4d63203d920bebd6a96f5f4aeccb21e5"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#a4d63203d920bebd6a96f5f4aeccb21e5">print_double_value</a></div><divclass="ttdeci">void print_double_value(double dval, int width, int precision)</div><divclass="ttdoc">The algorithm here is also the same as the print_int_value function.</div><divclass="ttdef"><b>Definition:</b> min_printf.h:206</div></div>
<divclass="ttc"id="amin__printf_8h_html_aa61e2407aab2c75e9837c77cab937d03"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#aa61e2407aab2c75e9837c77cab937d03">get_width_and_precision</a></div><divclass="ttdeci">char * get_width_and_precision(char *p, Buffer *buffer, int *width, int *precision)</div><divclass="ttdoc">Takes width and precision specified from the format of the string.</div><divclass="ttdef"><b>Definition:</b> min_printf.h:271</div></div>
<divclass="ttc"id="amin__printf_8h_html_ad2f9a02e1d69f58e2fb1248f49d09f4b"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#ad2f9a02e1d69f58e2fb1248f49d09f4b">put_char</a></div><divclass="ttdeci">void put_char(char s)</div><divclass="ttdoc">Prints one character on screen.</div><divclass="ttdef"><b>Definition:</b> min_printf.h:110</div></div>
<divclass="ttc"id="amin__printf_8h_html_af569209570eca8bc6770fb7d9dc873e6"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#af569209570eca8bc6770fb7d9dc873e6">print_string</a></div><divclass="ttdeci">void print_string(char *p, int width, int precision)</div><divclass="ttdef"><b>Definition:</b> min_printf.h:234</div></div>
<divclass="center"><iframescrolling="no"frameborder="0"src="../../d9/deb/min__printf_8h_a33e08c05f8c656a0fee465c2e8d2ecf9_cgraph.svg"width="632"height="386"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<p>This function return ten to the power a(The parameter specified to it) like: if the parameter specified is 4 i.e. -> power_of_ten(4) is called then this function will return ten to the power four (10000); </p><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">a</td><td>The power of ten which is to be returned </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>Ten to the power a </dd></dl>
<p>< This number will be returned as ten to power of a</p>
<divclass="line"><spanclass="lineno"> 46</span><spanclass="keywordtype">int</span> n = 1; <spanclass="comment">///< This number will be returned as ten to power of a</span></div>
<divclass="line"><spanclass="lineno"> 47</span><spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 1; i <= a; ++i)</div>
<divclass="line"><spanclass="lineno"> 48</span> n *= 10 ;</div>
<p>The algorithm here is also the same as the <code>print_int_value</code> function. </p>
<p>First, the digits before decimal is printed by converting the double to int. Then after printed a <code>.</code>, the double number is subtracted with the integer value of the number, leaving us with 0 before the decimal. Then, we multiply the number with 10 raised to the power precision ( precision means how many digits to be printed after the decimal.) By default, the precision is 8 if it is not specified. Then, the remaining number is printed on the screen. </p><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">dval</td><td>double number to be printed </td></tr>
<tr><tdclass="paramname">width</td><td>similar to width parameter of <aclass="el"href="../../d9/deb/min__printf_8h.html#a0a848efdf2ee124bba62e056eb9ab824">print_int_value()</a></td></tr>
<tr><tdclass="paramname">precision</td><td>tells the number of digits to be printed after the decimal (By default it is 8) </td></tr>
<divclass="line"><spanclass="lineno"> 208</span><spanclass="keywordtype">int</span> ndigits = <aclass="code hl_function"href="../../d9/deb/min__printf_8h.html#aefb40d94d5d9fa2a28bc64755dde096f">get_number_of_digits</a>((<spanclass="keywordtype">int</span>) dval); <spanclass="comment">// Store number of digits before decimal in dval</span></div>
<divclass="line"><spanclass="lineno"> 209</span><spanclass="keywordtype">int</span> reqd_blanks = width - (precision + 1) - ndigits; <spanclass="comment">// Blanks to be printed before printing dval, just to cover the width</span></div>
<divclass="line"><spanclass="lineno"> 211</span><aclass="code hl_function"href="../../d9/deb/min__printf_8h.html#a0a848efdf2ee124bba62e056eb9ab824">print_int_value</a>((<spanclass="keywordtype">int</span>) dval, reqd_blanks, 0); <spanclass="comment">// Prints the part before decimal</span></div>
<divclass="line"><spanclass="lineno"> 220</span> dval *= <aclass="code hl_function"href="../../d9/deb/min__printf_8h.html#a8421f89b76edcf21292c5100bfca586b">power_of_ten</a>(precision); <spanclass="comment">// Brings precision number of digits after decimal to before decimal</span></div>
<divclass="ttc"id="amin__printf_8h_html_aefb40d94d5d9fa2a28bc64755dde096f"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#aefb40d94d5d9fa2a28bc64755dde096f">get_number_of_digits</a></div><divclass="ttdeci">int get_number_of_digits(int n)</div><divclass="ttdoc">Calculates the number of digits in a number.</div><divclass="ttdef"><b>Definition:</b> min_printf.h:96</div></div>
<divclass="center"><iframescrolling="no"frameborder="0"src="../../d9/deb/min__printf_8h_a4d63203d920bebd6a96f5f4aeccb21e5_cgraph.svg"width="471"height="187"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<p>The algorithm here is to first convert the number into string and then reverse it be passing it to reverse_str function and then printing on the screen </p><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">n</td><td>Number to be printed </td></tr>
<tr><tdclass="paramname">width</td><td>Total characters to be printed (Prints ' ' if (size < width) </td></tr>
<tr><tdclass="paramname">precision</td><td>Total character of number to be printed (prints 0 before number if size of number < precision) </td></tr>
</table>
</dd>
</dl>
<p>< Used to store number of digits in number</p>
<p>The next two conditions check weather it is required to add blanks before printing the number (ie: width)and is it specified how many zeros to be printed before the number is printed (ie: precision)</p>
<divclass="line"><spanclass="lineno"> 158</span><spanclass="keywordtype">int</span> size = 0; <spanclass="comment">//!< Used to store number of digits in number</span></div>
<divclass="line"><spanclass="lineno"> 161</span> *s++ = n % 10 + <spanclass="charliteral">'0'</span>; <spanclass="comment">// Converts last digit of number to character and store it in p</span></div>
<divclass="line"><spanclass="lineno"> 163</span> n /= 10; <spanclass="comment">// Removes the last digit from the number n as we have successfully stored it in p</span></div>
<divclass="line"><spanclass="lineno"> 172</span><spanclass="comment"> * The next two conditions check weather it is required to </span></div>
<divclass="line"><spanclass="lineno"> 173</span><spanclass="comment"> * add blanks before printing the number (ie: width)and is it specified how many</span></div>
<divclass="line"><spanclass="lineno"> 174</span><spanclass="comment"> * zeros to be printed before the number is printed (ie: precision)</span></div>
<divclass="ttc"id="amalloc__dbg_8h_html_a9cc854374299a1dd933bf62029761768"><divclass="ttname"><ahref="../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768">free</a></div><divclass="ttdeci">#define free(ptr)</div><divclass="ttdoc">This macro replace the standard free function with free_dbg.</div><divclass="ttdef"><b>Definition:</b> malloc_dbg.h:26</div></div>
<divclass="ttc"id="amin__printf_8h_html_a8d68ec60643cacdb402176549565754e"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#a8d68ec60643cacdb402176549565754e">reverse_str</a></div><divclass="ttdeci">void reverse_str(char *p)</div><divclass="ttdoc">Reverses a string using two pointer algorithm</div><divclass="ttdef"><b>Definition:</b> min_printf.h:124</div></div>
<divclass="ttc"id="amin__printf_8h_html_ab47a4bec9213d96e1dba5171e5db0e25"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#ab47a4bec9213d96e1dba5171e5db0e25">INT_MAX_LENGTH</a></div><divclass="ttdeci">#define INT_MAX_LENGTH</div><divclass="ttdoc">for malloc and free functions for write function for va_start and va_arg functions</div><divclass="ttdef"><b>Definition:</b> min_printf.h:25</div></div>
<divclass="center"><iframescrolling="no"frameborder="0"src="../../d9/deb/min__printf_8h_a0a848efdf2ee124bba62e056eb9ab824_cgraph.svg"width="252"height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<p>First size of the string is calculated to check whether width and precision are to be taken into account or not. Then, the string is printed in accordingly. </p><dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">p</td><td>pointer to string to be printed </td></tr>
<tr><tdclass="paramname">width</td><td>if (width > sizeof string) then, blanks will be printed before sting to cover up the width </td></tr>
<tr><tdclass="paramname">precision</td><td>total characters of the string to be printed (prints the whole string if 0 or greater than size of string) </td></tr>
<divclass="line"><spanclass="lineno"> 236</span><spanclass="keywordtype">int</span> size = 0; <spanclass="comment">// Stores number of character in string</span></div>
<divclass="line"><spanclass="lineno"> 247</span><spanclass="comment">/* Checks how many characters to be printed.</span></div>
<divclass="line"><spanclass="lineno"> 248</span><spanclass="comment"> if precision is defined then size variable is changed to precision so that only precision</span></div>
<divclass="line"><spanclass="lineno"> 249</span><spanclass="comment"> number of characters were printed.</span></div>
<divclass="line"><spanclass="lineno"> 258</span><spanclass="comment">/* Print the string.*/</span></div>
<divclass="line"><spanclass="lineno"> 259</span><spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 0; i < size; ++i)</div>
<divclass="center"><iframescrolling="no"frameborder="0"src="../../d9/deb/min__printf_8h_af569209570eca8bc6770fb7d9dc873e6_cgraph.svg"width="218"height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<divclass="line"><spanclass="lineno"> 112</span><spanclass="comment">/* buf used for storing character to be printed in an array (+1 for '\0')*/</span></div>
<p>Reverses a string using <ahref="https://www.geeksforgeeks.org/program-reverse-array-using-pointers/?ref=rp"target="_blank">two pointer algorithm</a></p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">p</td><td>pointer to the string which is to be reversed </td></tr>
<divclass="line"><spanclass="lineno"> 126</span><spanclass="keywordtype">char</span> *l = p; <spanclass="comment">// Points to first character of p</span></div>
<divclass="line"><spanclass="lineno"> 127</span><spanclass="keywordtype">char</span> *h = p; <spanclass="comment">// Will be used to point to last character of p</span></div>
<divclass="line"><spanclass="lineno"> 128</span><spanclass="keywordtype">char</span> temp; <spanclass="comment">// Temporarily stores a character, Used in swapping</span></div>
<divclass="line"><spanclass="lineno"> 134</span><spanclass="comment">/* Swap character which lower and higher are pointing until lower < higher. At that point string will be reversed.*/</span></div>
<divclass="line"><spanclass="lineno"> 139</span> ++l; <spanclass="comment">// Increment lower to next character</span></div>
<divclass="line"><spanclass="lineno"> 140</span> --h; <spanclass="comment">// Decrement higher to previous character from current character</span></div>
<divclass="line"><spanclass="lineno"> 86</span><aclass="code hl_struct"href="../../dd/da2/structbuffer.html">buffer</a>->buffr_char = *c; <spanclass="comment">// Character initializes inside buffer->buffr_char</span></div>
<divclass="line"><spanclass="lineno"> 87</span><aclass="code hl_struct"href="../../dd/da2/structbuffer.html">buffer</a>->buf_size = 1; <spanclass="comment">// Sets bufsize to one as new character is stored in buffr_char</span></div>
<liclass="footer">Generated by <ahref="https://www.doxygen.org/index.html"><imgclass="footer"src="../../doxygen.svg"width="104"height="31"alt="doxygen"/></a> 1.9.5 </li>