<ahref="../../d9/deb/min__printf_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aid="l00001"name="l00001"></a><spanclass="lineno"> 1</span><spanclass="comment">/**</span></div>
<divclass="line"><aid="l00003"name="l00003"></a><spanclass="lineno"> 3</span><spanclass="comment"> * @brief Implementation of a [function](https://www.geeksforgeeks.org/variable-length-argument-c) similar to `printf`</span></div>
<divclass="line"><aid="l00005"name="l00005"></a><spanclass="lineno"> 5</span><spanclass="comment"> * `printf` statement rewritten (as `min_printf`) in C without using the `stdio.h` library </span></div>
<divclass="line"><aid="l00006"name="l00006"></a><spanclass="lineno"> 6</span><spanclass="comment"> * Syntax of `min_printf` is same as `printf`</span></div>
<divclass="line"><aid="l00007"name="l00007"></a><spanclass="lineno"> 7</span><spanclass="comment"> * Currently min_printf handles:</span></div>
<divclass="line"><aid="l00008"name="l00008"></a><spanclass="lineno"> 8</span><spanclass="comment"> * Integers, Doubles, floats, characters and strings</span></div>
<divclass="line"><aid="l00009"name="l00009"></a><spanclass="lineno"> 9</span><spanclass="comment"> * The format specifiers and escape sequence is the same as for `printf`</span></div>
<divclass="line"><aid="l00010"name="l00010"></a><spanclass="lineno"> 10</span><spanclass="comment"> * User can also specify the width and precision if required, just like in the case of `printf`</span></div>
<divclass="line"><aid="l00011"name="l00011"></a><spanclass="lineno"> 11</span><spanclass="comment"> * How to use it:</span></div>
<divclass="line"><aid="l00012"name="l00012"></a><spanclass="lineno"> 12</span><spanclass="comment"> * - First include min_printf.h in your code</span></div>
<divclass="line"><aid="l00013"name="l00013"></a><spanclass="lineno"> 13</span><spanclass="comment"> * - Then type `min_printf()`, and pass required parameters to it</span></div>
<divclass="line"><aid="l00014"name="l00014"></a><spanclass="lineno"> 14</span><spanclass="comment"> * - As already specified, it's syntax is same as printf </span></div>
<divclass="line"><aid="l00021"name="l00021"></a><spanclass="lineno"> 21</span><spanclass="preprocessor">#include <stdlib.h></span><spanclass="comment">/// for `malloc` and `free` functions</span></div>
<divclass="line"><aid="l00022"name="l00022"></a><spanclass="lineno"> 22</span><spanclass="preprocessor">#include <unistd.h></span><spanclass="comment">/// for `write` function</span></div>
<divclass="line"><aid="l00023"name="l00023"></a><spanclass="lineno"> 23</span><spanclass="preprocessor">#include <stdarg.h></span><spanclass="comment">/// for `va_start` and `va_arg` functions</span></div>
<divclass="line"><aid="l00025"name="l00025"></a><spanclass="lineno"><aclass="line"href="../../d9/deb/min__printf_8h.html#ab47a4bec9213d96e1dba5171e5db0e25"> 25</a></span><spanclass="preprocessor">#define INT_MAX_LENGTH 10 </span><spanclass="comment">/// used as standard length of string to store integers</span></div>
<divclass="line"><aid="l00026"name="l00026"></a><spanclass="lineno"> 26</span><spanclass="preprocessor">#define PRECISION_FOR_FLOAT 8 </span><spanclass="comment">/// default precision for float or double if not specified</span></div>
<divclass="line"><aid="l00029"name="l00029"></a><spanclass="lineno"> 29</span><spanclass="comment"> * @brief struct used to store character in certain times</span></div>
<divclass="line"><aid="l00032"name="l00032"></a><spanclass="lineno"> 32</span><spanclass="keywordtype">char</span> buffr_char; <spanclass="comment">// Character will be stored in this variable</span></div>
<divclass="line"><aid="l00033"name="l00033"></a><spanclass="lineno"> 33</span><spanclass="keywordtype">int</span> buf_size; <spanclass="comment">// Checks if character is present in buffr_char or not, 0 if no and 1 if yes</span></div>
<divclass="line"><aid="l00038"name="l00038"></a><spanclass="lineno"> 38</span><spanclass="comment"> * This function return ten to the power a(The parameter specified to it) like:</span></div>
<divclass="line"><aid="l00039"name="l00039"></a><spanclass="lineno"> 39</span><spanclass="comment"> * if the parameter specified is 4 i.e. -> power_of_ten(4) is called then</span></div>
<divclass="line"><aid="l00040"name="l00040"></a><spanclass="lineno"> 40</span><spanclass="comment"> * this function will return ten to the power four (10000);</span></div>
<divclass="line"><aid="l00041"name="l00041"></a><spanclass="lineno"> 41</span><spanclass="comment"> * @param a The power of ten which is to be returned</span></div>
<divclass="line"><aid="l00042"name="l00042"></a><spanclass="lineno"> 42</span><spanclass="comment"> * @return Ten to the power a</span></div>
<divclass="line"><aid="l00046"name="l00046"></a><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"><aid="l00047"name="l00047"></a><spanclass="lineno"> 47</span><spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 1; i <= a; ++i)</div>
<divclass="line"><aid="l00048"name="l00048"></a><spanclass="lineno"> 48</span> n *= 10 ;</div>
<divclass="line"><aid="l00053"name="l00053"></a><spanclass="lineno"> 53</span><spanclass="comment"> * @brief Checks if a character is a number</span></div>
<divclass="line"><aid="l00054"name="l00054"></a><spanclass="lineno"> 54</span><spanclass="comment"> * @param c character to be checked if it's a number or not</span></div>
<divclass="line"><aid="l00055"name="l00055"></a><spanclass="lineno"> 55</span><spanclass="comment"> * @return `true`(1) if the character is a number </span></div>
<divclass="line"><aid="l00056"name="l00056"></a><spanclass="lineno"> 56</span><spanclass="comment"> * @return `false`(0) if the character is NOT a number</span></div>
<divclass="line"><aid="l00064"name="l00064"></a><spanclass="lineno"> 64</span><spanclass="comment"> * @brief Returns specific required next character</span></div>
<divclass="line"><aid="l00065"name="l00065"></a><spanclass="lineno"> 65</span><spanclass="comment"> * @param p pointer to a format string of `min_printf()`</span></div>
<divclass="line"><aid="l00066"name="l00066"></a><spanclass="lineno"> 66</span><spanclass="comment"> * @param buffer struct for checking if buffr_char character is present or not</span></div>
<divclass="line"><aid="l00067"name="l00067"></a><spanclass="lineno"> 67</span><spanclass="comment"> * @return character inside `buffer->buffr_char`, if `buffer->buf_size` is one</span></div>
<divclass="line"><aid="l00068"name="l00068"></a><spanclass="lineno"> 68</span><spanclass="comment"> * @return character at which p is pointing, if `buffer->buf_size` is zero</span></div>
<divclass="line"><aid="l00073"name="l00073"></a><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"><aid="l00074"name="l00074"></a><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="line"><aid="l00080"name="l00080"></a><spanclass="lineno"> 80</span><spanclass="comment"> * @brief Stores character to the `buffer->buffr_char`</span></div>
<divclass="line"><aid="l00081"name="l00081"></a><spanclass="lineno"> 81</span><spanclass="comment"> * @param c character to be stored in the `buffer->buffr_char`</span></div>
<divclass="line"><aid="l00082"name="l00082"></a><spanclass="lineno"> 82</span><spanclass="comment"> * @param buffer struct where character will be stored</span></div>
<divclass="line"><aid="l00086"name="l00086"></a><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"><aid="l00087"name="l00087"></a><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>
<divclass="line"><aid="l00092"name="l00092"></a><spanclass="lineno"> 92</span><spanclass="comment"> * @brief Calculates the number of digits in a number</span></div>
<divclass="line"><aid="l00093"name="l00093"></a><spanclass="lineno"> 93</span><spanclass="comment"> * @param n number whose digits are to be counted</span></div>
<divclass="line"><aid="l00094"name="l00094"></a><spanclass="lineno"> 94</span><spanclass="comment"> * @return number of digits in n</span></div>
<divclass="line"><aid="l00100"name="l00100"></a><spanclass="lineno"> 100</span> ++digits; <spanclass="comment">// Since number still contains a digit, so increment digit variable</span></div>
<divclass="line"><aid="l00101"name="l00101"></a><spanclass="lineno"> 101</span> n /= 10; <spanclass="comment">// Removes last digit from number</span></div>
<divclass="line"><aid="l00107"name="l00107"></a><spanclass="lineno"> 107</span><spanclass="comment"> * @brief Prints one character on screen</span></div>
<divclass="line"><aid="l00108"name="l00108"></a><spanclass="lineno"> 108</span><spanclass="comment"> * @param s character to be printed on the screen</span></div>
<divclass="line"><aid="l00112"name="l00112"></a><spanclass="lineno"> 112</span><spanclass="comment">/* buf used for storing character to be printed in an array (+1 for '\0')*/</span></div>
<divclass="line"><aid="l00121"name="l00121"></a><spanclass="lineno"> 121</span><spanclass="comment"> * @brief Reverses a string using [two pointer algorithm](https://www.geeksforgeeks.org/program-reverse-array-using-pointers/?ref=rp)</span></div>
<divclass="line"><aid="l00122"name="l00122"></a><spanclass="lineno"> 122</span><spanclass="comment"> * @param p pointer to the string which is to be reversed</span></div>
<divclass="line"><aid="l00126"name="l00126"></a><spanclass="lineno"> 126</span><spanclass="keywordtype">char</span> *l = p; <spanclass="comment">// Points to first character of p</span></div>
<divclass="line"><aid="l00127"name="l00127"></a><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"><aid="l00128"name="l00128"></a><spanclass="lineno"> 128</span><spanclass="keywordtype">char</span> temp; <spanclass="comment">// Temporarily stores a character, Used in swapping</span></div>
<divclass="line"><aid="l00132"name="l00132"></a><spanclass="lineno"> 132</span> --h; <spanclass="comment">// Now h point to last valid character of string </span></div>
<divclass="line"><aid="l00134"name="l00134"></a><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"><aid="l00139"name="l00139"></a><spanclass="lineno"> 139</span> ++l; <spanclass="comment">// Increment lower to next character</span></div>
<divclass="line"><aid="l00140"name="l00140"></a><spanclass="lineno"> 140</span> --h; <spanclass="comment">// Decrement higher to previous character from current character</span></div>
<divclass="line"><aid="l00146"name="l00146"></a><spanclass="lineno"> 146</span><spanclass="comment"> * The algorithm here is to first convert the number into </span></div>
<divclass="line"><aid="l00147"name="l00147"></a><spanclass="lineno"> 147</span><spanclass="comment"> * string and then reverse it be passing it to reverse_str function</span></div>
<divclass="line"><aid="l00148"name="l00148"></a><spanclass="lineno"> 148</span><spanclass="comment"> * and then printing on the screen</span></div>
<divclass="line"><aid="l00149"name="l00149"></a><spanclass="lineno"> 149</span><spanclass="comment"> * @param n Number to be printed</span></div>
<divclass="line"><aid="l00150"name="l00150"></a><spanclass="lineno"> 150</span><spanclass="comment"> * @param width Total characters to be printed (Prints '' if (size < width)</span></div>
<divclass="line"><aid="l00151"name="l00151"></a><spanclass="lineno"> 151</span><spanclass="comment"> * @param precision Total character of number to be printed (prints 0 before number if size of number < precision)</span></div>
<divclass="line"><aid="l00158"name="l00158"></a><spanclass="lineno"> 158</span><spanclass="keywordtype">int</span> size = 0; <spanclass="comment">//!< Used to store number of digits in number</span></div>
<divclass="line"><aid="l00161"name="l00161"></a><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"><aid="l00162"name="l00162"></a><spanclass="lineno"> 162</span> ++size; <spanclass="comment">// Increment size variable as one more digit is occured</span></div>
<divclass="line"><aid="l00163"name="l00163"></a><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"><aid="l00167"name="l00167"></a><spanclass="lineno"> 167</span> s = p; <spanclass="comment">// Again point back s to starting of p</span></div>
<divclass="line"><aid="l00172"name="l00172"></a><spanclass="lineno"> 172</span><spanclass="comment"> * The next two conditions check weather it is required to </span></div>
<divclass="line"><aid="l00173"name="l00173"></a><spanclass="lineno"> 173</span><spanclass="comment"> * add blanks before printing the number (ie: width)and is it specified how many</span></div>
<divclass="line"><aid="l00174"name="l00174"></a><spanclass="lineno"> 174</span><spanclass="comment"> * zeros to be printed before the number is printed (ie: precision)</span></div>
<divclass="line"><aid="l00192"name="l00192"></a><spanclass="lineno"> 192</span><spanclass="comment">* @brief The algorithm here is also the same as the `print_int_value` function</span></div>
<divclass="line"><aid="l00195"name="l00195"></a><spanclass="lineno"> 195</span><spanclass="comment"> * First, the digits before decimal is printed by converting the double </span></div>
<divclass="line"><aid="l00196"name="l00196"></a><spanclass="lineno"> 196</span><spanclass="comment"> * to int. Then after printed a `.`, the double number is subtracted with</span></div>
<divclass="line"><aid="l00197"name="l00197"></a><spanclass="lineno"> 197</span><spanclass="comment"> * the integer value of the number, leaving us with 0 before the decimal.</span></div>
<divclass="line"><aid="l00198"name="l00198"></a><spanclass="lineno"> 198</span><spanclass="comment"> * Then, we multiply the number with 10 raised to the power precision (</span></div>
<divclass="line"><aid="l00199"name="l00199"></a><spanclass="lineno"> 199</span><spanclass="comment"> * precision means how many digits to be printed after the decimal.)</span></div>
<divclass="line"><aid="l00200"name="l00200"></a><spanclass="lineno"> 200</span><spanclass="comment"> * By default, the precision is 8 if it is not specified.</span></div>
<divclass="line"><aid="l00201"name="l00201"></a><spanclass="lineno"> 201</span><spanclass="comment"> * Then, the remaining number is printed on the screen.</span></div>
<divclass="line"><aid="l00202"name="l00202"></a><spanclass="lineno"> 202</span><spanclass="comment"> * @param dval double number to be printed</span></div>
<divclass="line"><aid="l00203"name="l00203"></a><spanclass="lineno"> 203</span><spanclass="comment"> * @param width similar to width parameter of print_int_value()</span></div>
<divclass="line"><aid="l00204"name="l00204"></a><spanclass="lineno"> 204</span><spanclass="comment"> * @param precision tells the number of digits to be printed after the decimal (By default it is 8)</span></div>
<divclass="line"><aid="l00208"name="l00208"></a><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"><aid="l00209"name="l00209"></a><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"><aid="l00211"name="l00211"></a><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"><aid="l00215"name="l00215"></a><spanclass="lineno"> 215</span><spanclass="comment">/*Deletes digits before decimal and makes them zero. For example:</span></div>
<divclass="line"><aid="l00216"name="l00216"></a><spanclass="lineno"> 216</span><spanclass="comment"> if dval = 1923.79022, them this will make dval = 0.79022</span></div>
<divclass="line"><aid="l00220"name="l00220"></a><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="line"><aid="l00227"name="l00227"></a><spanclass="lineno"> 227</span><spanclass="comment">* First size of the string is calculated to check whether</span></div>
<divclass="line"><aid="l00228"name="l00228"></a><spanclass="lineno"> 228</span><spanclass="comment">* width and precision are to be taken into account or not.</span></div>
<divclass="line"><aid="l00229"name="l00229"></a><spanclass="lineno"> 229</span><spanclass="comment">* Then, the string is printed in accordingly.</span></div>
<divclass="line"><aid="l00230"name="l00230"></a><spanclass="lineno"> 230</span><spanclass="comment">* @param p pointer to string to be printed</span></div>
<divclass="line"><aid="l00231"name="l00231"></a><spanclass="lineno"> 231</span><spanclass="comment">* @param width if (width > sizeof string) then, blanks will be printed before sting to cover up the width</span></div>
<divclass="line"><aid="l00232"name="l00232"></a><spanclass="lineno"> 232</span><spanclass="comment">* @param precision total characters of the string to be printed (prints the whole string if 0 or greater than size of string)</span></div>
<divclass="line"><aid="l00236"name="l00236"></a><spanclass="lineno"> 236</span><spanclass="keywordtype">int</span> size = 0; <spanclass="comment">// Stores number of character in string</span></div>
<divclass="line"><aid="l00247"name="l00247"></a><spanclass="lineno"> 247</span><spanclass="comment">/* Checks how many characters to be printed.</span></div>
<divclass="line"><aid="l00248"name="l00248"></a><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"><aid="l00249"name="l00249"></a><spanclass="lineno"> 249</span><spanclass="comment"> number of characters were printed.</span></div>
<divclass="line"><aid="l00254"name="l00254"></a><spanclass="lineno"> 254</span><spanclass="comment">/* Prints blanks to cover the width if required*/</span></div>
<divclass="line"><aid="l00255"name="l00255"></a><spanclass="lineno"> 255</span><spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 0; i < (width - size); ++i)</div>
<divclass="line"><aid="l00258"name="l00258"></a><spanclass="lineno"> 258</span><spanclass="comment">/* Print the string.*/</span></div>
<divclass="line"><aid="l00259"name="l00259"></a><spanclass="lineno"> 259</span><spanclass="keywordflow">for</span> (<spanclass="keywordtype">int</span> i = 0; i < size; ++i)</div>
<divclass="line"><aid="l00265"name="l00265"></a><spanclass="lineno"> 265</span><spanclass="comment">* @brief Takes width and precision specified from the format of the string</span></div>
<divclass="line"><aid="l00266"name="l00266"></a><spanclass="lineno"> 266</span><spanclass="comment">* @param p pointer of the format string</span></div>
<divclass="line"><aid="l00267"name="l00267"></a><spanclass="lineno"> 267</span><spanclass="comment">* @param width variable in which width will be stored</span></div>
<divclass="line"><aid="l00268"name="l00268"></a><spanclass="lineno"> 268</span><spanclass="comment">* @param precision variable in which precision will be stored</span></div>
<divclass="line"><aid="l00269"name="l00269"></a><spanclass="lineno"> 269</span><spanclass="comment">* @return character pointer to the current pointer of string p (used to update value of p)</span></div>
<divclass="line"><aid="l00281"name="l00281"></a><spanclass="lineno"> 281</span><spanclass="comment">/* Calculates the precision specified.*/</span></div>
<divclass="line"><aid="l00282"name="l00282"></a><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"><aid="l00285"name="l00285"></a><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="line"><aid="l00291"name="l00291"></a><spanclass="lineno"> 291</span><spanclass="comment"> * min_printf is the function same as printf</span></div>
<divclass="line"><aid="l00292"name="l00292"></a><spanclass="lineno"> 292</span><spanclass="comment"> * @param fmt format of string</span></div>
<divclass="line"><aid="l00293"name="l00293"></a><spanclass="lineno"> 293</span><spanclass="comment"> * @param ... arguments passed according to the format</span></div>
<divclass="line"><aid="l00297"name="l00297"></a><spanclass="lineno"> 297</span> va_list ap; <spanclass="comment">// Points to each unnamed arg in turn</span></div>
<divclass="line"><aid="l00298"name="l00298"></a><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"><aid="l00299"name="l00299"></a><spanclass="lineno"> 299</span><spanclass="keywordtype">char</span> cval; <spanclass="comment">// Stores character value</span></div>
<divclass="line"><aid="l00300"name="l00300"></a><spanclass="lineno"> 300</span><spanclass="keywordtype">int</span> ival; <spanclass="comment">// For integer values</span></div>
<divclass="line"><aid="l00301"name="l00301"></a><spanclass="lineno"> 301</span><spanclass="keywordtype">double</span> dval; <spanclass="comment">// For double or float values</span></div>
<divclass="line"><aid="l00302"name="l00302"></a><spanclass="lineno"> 302</span> va_start(ap, fmt); <spanclass="comment">// Makes ap points to first unnames argument</span></div>
<divclass="line"><aid="l00304"name="l00304"></a><spanclass="lineno"> 304</span><spanclass="comment">/* Initializing the buffer for storing character. */</span></div>
<divclass="line"><aid="l00306"name="l00306"></a><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="line"><aid="l00310"name="l00310"></a><spanclass="lineno"> 310</span><spanclass="comment">/* If p != '%' then the character is printed to screen. */</span></div>
<divclass="line"><aid="l00319"name="l00319"></a><spanclass="lineno"> 319</span><spanclass="comment">/* Updates values of width, precision and p. */</span></div>
<divclass="line"><aid="l00335"name="l00335"></a><spanclass="lineno"> 335</span><spanclass="comment">// If precision is not specified then default value is applied</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="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_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_a33e08c05f8c656a0fee465c2e8d2ecf9"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#a33e08c05f8c656a0fee465c2e8d2ecf9">min_printf</a></div><divclass="ttdeci">void min_printf(char *fmt,...)</div><divclass="ttdoc">min_printf is the function same as printf</div><divclass="ttdef"><b>Definition:</b> min_printf.h:295</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_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_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_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_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="ttc"id="amin__printf_8h_html_abf0876f583782407c9e15c60158eec52"><divclass="ttname"><ahref="../../d9/deb/min__printf_8h.html#abf0876f583782407c9e15c60158eec52">Buffer</a></div><divclass="ttdeci">struct buffer Buffer</div><divclass="ttdoc">struct used to store character in certain times</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_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="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="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="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>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->
<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>