TheAlgorithms-C/db/d0c/infix__to__postfix_8c.html
2022-01-14 20:11:27 +00:00

537 lines
39 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.3"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C: conversions/infix_to_postfix.c File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">Algorithms_in_C<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.3 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('db/d0c/infix__to__postfix_8c.html','../../'); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle"><div class="title">infix_to_postfix.c File Reference</div></div>
</div><!--header-->
<div class="contents">
<p><a href="https://condor.depaul.edu/ichu/csc415/notes/notes9/Infix.htm" target="_blank">Infix to Postfix</a> Expression Conversion
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;stdio.h&gt;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for infix_to_postfix.c:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dc/dc9/infix__to__postfix_8c__incl.svg" width="150" height="127"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d10/struct_stack.html">Stack</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">for printf() and scanf() <a href="../../dd/d10/struct_stack.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a613462735d30cae1b85b606ecab30554"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../db/d0c/infix__to__postfix_8c.html#a613462735d30cae1b85b606ecab30554">push</a> (struct <a class="el" href="../../dd/d10/struct_stack.html">Stack</a> *p, char x)</td></tr>
<tr class="memdesc:a613462735d30cae1b85b606ecab30554"><td class="mdescLeft">&#160;</td><td class="mdescRight">push function <a href="../../db/d0c/infix__to__postfix_8c.html#a613462735d30cae1b85b606ecab30554">More...</a><br /></td></tr>
<tr class="separator:a613462735d30cae1b85b606ecab30554"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a940cdcd27c40699eebb4ef113b2d9451"><td class="memItemLeft" align="right" valign="top">char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../db/d0c/infix__to__postfix_8c.html#a940cdcd27c40699eebb4ef113b2d9451">pop</a> (struct <a class="el" href="../../dd/d10/struct_stack.html">Stack</a> *p)</td></tr>
<tr class="memdesc:a940cdcd27c40699eebb4ef113b2d9451"><td class="mdescLeft">&#160;</td><td class="mdescRight">pop function <a href="../../db/d0c/infix__to__postfix_8c.html#a940cdcd27c40699eebb4ef113b2d9451">More...</a><br /></td></tr>
<tr class="separator:a940cdcd27c40699eebb4ef113b2d9451"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afd8245c04b202240390de23170f72d6b"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../db/d0c/infix__to__postfix_8c.html#afd8245c04b202240390de23170f72d6b">isOprnd</a> (char ch)</td></tr>
<tr class="memdesc:afd8245c04b202240390de23170f72d6b"><td class="mdescLeft">&#160;</td><td class="mdescRight">isOprnd function <a href="../../db/d0c/infix__to__postfix_8c.html#afd8245c04b202240390de23170f72d6b">More...</a><br /></td></tr>
<tr class="separator:afd8245c04b202240390de23170f72d6b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afa8471c76bc57b12ad21de22beb39021"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../db/d0c/infix__to__postfix_8c.html#afa8471c76bc57b12ad21de22beb39021">isEmpty</a> (struct <a class="el" href="../../dd/d10/struct_stack.html">Stack</a> s)</td></tr>
<tr class="memdesc:afa8471c76bc57b12ad21de22beb39021"><td class="mdescLeft">&#160;</td><td class="mdescRight">isEmpty function <a href="../../db/d0c/infix__to__postfix_8c.html#afa8471c76bc57b12ad21de22beb39021">More...</a><br /></td></tr>
<tr class="separator:afa8471c76bc57b12ad21de22beb39021"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac91f38ad7885fca93e39325361a5c787"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../db/d0c/infix__to__postfix_8c.html#ac91f38ad7885fca93e39325361a5c787">getPrecedence</a> (char op1, char op2)</td></tr>
<tr class="memdesc:ac91f38ad7885fca93e39325361a5c787"><td class="mdescLeft">&#160;</td><td class="mdescRight">getPrecedence function returns the precedence after comparing two operators passed as parameter. <a href="../../db/d0c/infix__to__postfix_8c.html#ac91f38ad7885fca93e39325361a5c787">More...</a><br /></td></tr>
<tr class="separator:ac91f38ad7885fca93e39325361a5c787"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a92af69ffc1e1f965ebce6a44672e96b1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../db/d0c/infix__to__postfix_8c.html#a92af69ffc1e1f965ebce6a44672e96b1">convert</a> (char infix[], char postfix[])</td></tr>
<tr class="memdesc:a92af69ffc1e1f965ebce6a44672e96b1"><td class="mdescLeft">&#160;</td><td class="mdescRight">convert function <a href="../../db/d0c/infix__to__postfix_8c.html#a92af69ffc1e1f965ebce6a44672e96b1">More...</a><br /></td></tr>
<tr class="separator:a92af69ffc1e1f965ebce6a44672e96b1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../db/d0c/infix__to__postfix_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">main function <a href="../../db/d0c/infix__to__postfix_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">More...</a><br /></td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p ><a href="https://condor.depaul.edu/ichu/csc415/notes/notes9/Infix.htm" target="_blank">Infix to Postfix</a> Expression Conversion </p>
<p >Convert Infixed expressions to Postfix expression. </p><dl class="section author"><dt>Author</dt><dd><a href="https://github.com/harshcut" target="_blank">Harsh Karande</a> </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a92af69ffc1e1f965ebce6a44672e96b1" name="a92af69ffc1e1f965ebce6a44672e96b1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a92af69ffc1e1f965ebce6a44672e96b1">&#9670;&nbsp;</a></span>convert()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void convert </td>
<td>(</td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>infix</em>[], </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>postfix</em>[]&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>convert function </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">infix[]</td><td>: infix array provided by user </td></tr>
<tr><td class="paramname">postfix[]</td><td>: empty array to be given to <a class="el" href="../../db/d0c/infix__to__postfix_8c.html#a92af69ffc1e1f965ebce6a44672e96b1" title="convert function">convert()</a> </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>postfixed expresion or \0 on exit </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 131</span>{</div>
<div class="line"><span class="lineno"> 132</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../dd/d10/struct_stack.html">Stack</a> s; <span class="comment">// initialze object reference of stack</span></div>
<div class="line"><span class="lineno"> 133</span> s.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ac2dbef151bc913684a90b06836725ef9">tos</a> = -1; <span class="comment">// initalize the tos</span></div>
<div class="line"><span class="lineno"> 134</span> </div>
<div class="line"><span class="lineno"> 135</span> <span class="keywordtype">int</span> i, j = 0, pr;</div>
<div class="line"><span class="lineno"> 136</span> <span class="keywordtype">char</span> ch, temp;</div>
<div class="line"><span class="lineno"> 137</span> </div>
<div class="line"><span class="lineno"> 138</span> <span class="keywordflow">for</span> (i = 0; infix[i] != <span class="charliteral">&#39;\0&#39;</span>; i++)</div>
<div class="line"><span class="lineno"> 139</span> {</div>
<div class="line"><span class="lineno"> 140</span> ch = infix[i];</div>
<div class="line"><span class="lineno"> 141</span> </div>
<div class="line"><span class="lineno"> 142</span> <span class="keywordflow">if</span> (<a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#afd8245c04b202240390de23170f72d6b">isOprnd</a>(ch) == 1) <span class="comment">// check if char is operand or operator</span></div>
<div class="line"><span class="lineno"> 143</span> {</div>
<div class="line"><span class="lineno"> 144</span> postfix[j] = ch; <span class="comment">// assign ch to postfix array with index j</span></div>
<div class="line"><span class="lineno"> 145</span> j++; <span class="comment">// incement j</span></div>
<div class="line"><span class="lineno"> 146</span> }</div>
<div class="line"><span class="lineno"> 147</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 148</span> {</div>
<div class="line"><span class="lineno"> 149</span> <span class="keywordflow">if</span> (ch == <span class="charliteral">&#39;(&#39;</span>)</div>
<div class="line"><span class="lineno"> 150</span> {</div>
<div class="line"><span class="lineno"> 151</span> <a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#a613462735d30cae1b85b606ecab30554">push</a>(&amp;s, ch);</div>
<div class="line"><span class="lineno"> 152</span> }</div>
<div class="line"><span class="lineno"> 153</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 154</span> {</div>
<div class="line"><span class="lineno"> 155</span> <span class="keywordflow">if</span> (ch == <span class="charliteral">&#39;)&#39;</span>)</div>
<div class="line"><span class="lineno"> 156</span> {</div>
<div class="line"><span class="lineno"> 157</span> <span class="keywordflow">while</span> ((temp = <a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#a940cdcd27c40699eebb4ef113b2d9451">pop</a>(&amp;s)) != <span class="charliteral">&#39;(&#39;</span>)</div>
<div class="line"><span class="lineno"> 158</span> {</div>
<div class="line"><span class="lineno"> 159</span> postfix[j] = temp;</div>
<div class="line"><span class="lineno"> 160</span> j++;</div>
<div class="line"><span class="lineno"> 161</span> }</div>
<div class="line"><span class="lineno"> 162</span> }</div>
<div class="line"><span class="lineno"> 163</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 164</span> {</div>
<div class="line"><span class="lineno"> 165</span> <span class="keywordflow">while</span> (<a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#afa8471c76bc57b12ad21de22beb39021">isEmpty</a>(s) == 0) <span class="comment">// check if stack is empty</span></div>
<div class="line"><span class="lineno"> 166</span> {</div>
<div class="line"><span class="lineno"> 167</span> pr = <a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#ac91f38ad7885fca93e39325361a5c787">getPrecedence</a> (ch,</div>
<div class="line"><span class="lineno"> 168</span> s.arr[s.tos]); <span class="comment">// check operator precedence</span></div>
<div class="line"><span class="lineno"> 169</span> </div>
<div class="line"><span class="lineno"> 170</span> <span class="keywordflow">if</span> (pr == 1)</div>
<div class="line"><span class="lineno"> 171</span> {</div>
<div class="line"><span class="lineno"> 172</span> <span class="keywordflow">break</span>; <span class="comment">// if ch has a greater precedence than</span></div>
<div class="line"><span class="lineno"> 173</span> <span class="comment">// s.arr[s.top]</span></div>
<div class="line"><span class="lineno"> 174</span> }</div>
<div class="line"><span class="lineno"> 175</span> </div>
<div class="line"><span class="lineno"> 176</span> postfix[j] = <a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#a940cdcd27c40699eebb4ef113b2d9451">pop</a>(&amp;s);</div>
<div class="line"><span class="lineno"> 177</span> j++;</div>
<div class="line"><span class="lineno"> 178</span> }</div>
<div class="line"><span class="lineno"> 179</span> </div>
<div class="line"><span class="lineno"> 180</span> <a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#a613462735d30cae1b85b606ecab30554">push</a>(&amp;s, ch); <span class="comment">// push ch to stack</span></div>
<div class="line"><span class="lineno"> 181</span> }</div>
<div class="line"><span class="lineno"> 182</span> }</div>
<div class="line"><span class="lineno"> 183</span> }</div>
<div class="line"><span class="lineno"> 184</span> }</div>
<div class="line"><span class="lineno"> 185</span> </div>
<div class="line"><span class="lineno"> 186</span> <span class="keywordflow">while</span> (<a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#afa8471c76bc57b12ad21de22beb39021">isEmpty</a>(s) == 0) <span class="comment">// check if stack is empty</span></div>
<div class="line"><span class="lineno"> 187</span> {</div>
<div class="line"><span class="lineno"> 188</span> postfix[j] = <a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#a940cdcd27c40699eebb4ef113b2d9451">pop</a>(&amp;s);</div>
<div class="line"><span class="lineno"> 189</span> j++;</div>
<div class="line"><span class="lineno"> 190</span> }</div>
<div class="line"><span class="lineno"> 191</span> </div>
<div class="line"><span class="lineno"> 192</span> postfix[j] = <span class="charliteral">&#39;\0&#39;</span>;</div>
<div class="line"><span class="lineno"> 193</span>}</div>
<div class="ttc" id="ainfix__to__postfix_8c_html_a613462735d30cae1b85b606ecab30554"><div class="ttname"><a href="../../db/d0c/infix__to__postfix_8c.html#a613462735d30cae1b85b606ecab30554">push</a></div><div class="ttdeci">void push(struct Stack *p, char ch)</div><div class="ttdoc">push function</div><div class="ttdef"><b>Definition:</b> infix_to_postfix.c:55</div></div>
<div class="ttc" id="ainfix__to__postfix_8c_html_a940cdcd27c40699eebb4ef113b2d9451"><div class="ttname"><a href="../../db/d0c/infix__to__postfix_8c.html#a940cdcd27c40699eebb4ef113b2d9451">pop</a></div><div class="ttdeci">char pop(struct Stack *p)</div><div class="ttdoc">pop function</div><div class="ttdef"><b>Definition:</b> infix_to_postfix.c:72</div></div>
<div class="ttc" id="ainfix__to__postfix_8c_html_ac91f38ad7885fca93e39325361a5c787"><div class="ttname"><a href="../../db/d0c/infix__to__postfix_8c.html#ac91f38ad7885fca93e39325361a5c787">getPrecedence</a></div><div class="ttdeci">int getPrecedence(char op1, char op2)</div><div class="ttdoc">getPrecedence function returns the precedence after comparing two operators passed as parameter.</div><div class="ttdef"><b>Definition:</b> infix_to_postfix.c:201</div></div>
<div class="ttc" id="ainfix__to__postfix_8c_html_afa8471c76bc57b12ad21de22beb39021"><div class="ttname"><a href="../../db/d0c/infix__to__postfix_8c.html#afa8471c76bc57b12ad21de22beb39021">isEmpty</a></div><div class="ttdeci">int isEmpty(struct Stack s)</div><div class="ttdoc">isEmpty function</div><div class="ttdef"><b>Definition:</b> infix_to_postfix.c:112</div></div>
<div class="ttc" id="ainfix__to__postfix_8c_html_afd8245c04b202240390de23170f72d6b"><div class="ttname"><a href="../../db/d0c/infix__to__postfix_8c.html#afd8245c04b202240390de23170f72d6b">isOprnd</a></div><div class="ttdeci">int isOprnd(char ch)</div><div class="ttdoc">isOprnd function</div><div class="ttdef"><b>Definition:</b> infix_to_postfix.c:93</div></div>
<div class="ttc" id="astruct_stack_html"><div class="ttname"><a href="../../dd/d10/struct_stack.html">Stack</a></div><div class="ttdoc">for printf() and scanf()</div><div class="ttdef"><b>Definition:</b> infix_to_postfix.c:18</div></div>
<div class="ttc" id="astruct_stack_html_ac2dbef151bc913684a90b06836725ef9"><div class="ttname"><a href="../../dd/d10/struct_stack.html#ac2dbef151bc913684a90b06836725ef9">Stack::tos</a></div><div class="ttdeci">int tos</div><div class="ttdoc">static array of integers</div><div class="ttdef"><b>Definition:</b> infix_to_postfix.c:20</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/d0c/infix__to__postfix_8c_a92af69ffc1e1f965ebce6a44672e96b1_cgraph.svg" width="234" height="240"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="ac91f38ad7885fca93e39325361a5c787" name="ac91f38ad7885fca93e39325361a5c787"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac91f38ad7885fca93e39325361a5c787">&#9670;&nbsp;</a></span>getPrecedence()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int getPrecedence </td>
<td>(</td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>op1</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>op2</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>getPrecedence function returns the precedence after comparing two operators passed as parameter. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">op1</td><td>: first operator </td></tr>
<tr><td class="paramname">op2</td><td>: second operator </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>1 or 0 on exit </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 202</span>{</div>
<div class="line"><span class="lineno"> 203</span> <span class="keywordflow">if</span> (op2 == <span class="charliteral">&#39;$&#39;</span>)</div>
<div class="line"><span class="lineno"> 204</span> {</div>
<div class="line"><span class="lineno"> 205</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 206</span> }</div>
<div class="line"><span class="lineno"> 207</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (op1 == <span class="charliteral">&#39;$&#39;</span>)</div>
<div class="line"><span class="lineno"> 208</span> {</div>
<div class="line"><span class="lineno"> 209</span> <span class="keywordflow">return</span> 1;</div>
<div class="line"><span class="lineno"> 210</span> }</div>
<div class="line"><span class="lineno"> 211</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (op2 == <span class="charliteral">&#39;*&#39;</span> || op2 == <span class="charliteral">&#39;/&#39;</span> || op2 == <span class="charliteral">&#39;%&#39;</span>)</div>
<div class="line"><span class="lineno"> 212</span> {</div>
<div class="line"><span class="lineno"> 213</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 214</span> }</div>
<div class="line"><span class="lineno"> 215</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (op1 == <span class="charliteral">&#39;*&#39;</span> || op1 == <span class="charliteral">&#39;/&#39;</span> || op1 == <span class="charliteral">&#39;%&#39;</span>)</div>
<div class="line"><span class="lineno"> 216</span> {</div>
<div class="line"><span class="lineno"> 217</span> <span class="keywordflow">return</span> 1;</div>
<div class="line"><span class="lineno"> 218</span> }</div>
<div class="line"><span class="lineno"> 219</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (op2 == <span class="charliteral">&#39;+&#39;</span> || op2 == <span class="charliteral">&#39;-&#39;</span>)</div>
<div class="line"><span class="lineno"> 220</span> {</div>
<div class="line"><span class="lineno"> 221</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 222</span> }</div>
<div class="line"><span class="lineno"> 223</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 224</span> {</div>
<div class="line"><span class="lineno"> 225</span> <span class="keywordflow">return</span> 1;</div>
<div class="line"><span class="lineno"> 226</span> }</div>
<div class="line"><span class="lineno"> 227</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="afa8471c76bc57b12ad21de22beb39021" name="afa8471c76bc57b12ad21de22beb39021"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afa8471c76bc57b12ad21de22beb39021">&#9670;&nbsp;</a></span>isEmpty()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int isEmpty </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../dd/d10/struct_stack.html">Stack</a>&#160;</td>
<td class="paramname"><em>s</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>isEmpty function </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">s</td><td>: it is the object reference of stack </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>1 or 0 on exit </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 113</span>{</div>
<div class="line"><span class="lineno"> 114</span> <span class="keywordflow">if</span> (s.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ac2dbef151bc913684a90b06836725ef9">tos</a> == -1) <span class="comment">// check if stack is empty</span></div>
<div class="line"><span class="lineno"> 115</span> {</div>
<div class="line"><span class="lineno"> 116</span> <span class="keywordflow">return</span> 1; <span class="comment">// return for true result</span></div>
<div class="line"><span class="lineno"> 117</span> }</div>
<div class="line"><span class="lineno"> 118</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 119</span> {</div>
<div class="line"><span class="lineno"> 120</span> <span class="keywordflow">return</span> 0; <span class="comment">// return for false result</span></div>
<div class="line"><span class="lineno"> 121</span> }</div>
<div class="line"><span class="lineno"> 122</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="afd8245c04b202240390de23170f72d6b" name="afd8245c04b202240390de23170f72d6b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afd8245c04b202240390de23170f72d6b">&#9670;&nbsp;</a></span>isOprnd()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int isOprnd </td>
<td>(</td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>ch</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>isOprnd function </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ch</td><td>: this is the element from the infix array </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>1 or 0 on exit </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 94</span>{</div>
<div class="line"><span class="lineno"> 95</span> <span class="keywordflow">if</span> ((ch &gt;= 65 &amp;&amp; ch &lt;= 90) ||</div>
<div class="line"><span class="lineno"> 96</span> (ch &gt;= 97 &amp;&amp; ch &lt;= 122) || <span class="comment">// check if ch is an operator or</span></div>
<div class="line"><span class="lineno"> 97</span> (ch &gt;= 48 &amp;&amp; ch &lt;= 57)) <span class="comment">// operand using ASCII values</span></div>
<div class="line"><span class="lineno"> 98</span> {</div>
<div class="line"><span class="lineno"> 99</span> <span class="keywordflow">return</span> 1; <span class="comment">// return for true result</span></div>
<div class="line"><span class="lineno"> 100</span> }</div>
<div class="line"><span class="lineno"> 101</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 102</span> {</div>
<div class="line"><span class="lineno"> 103</span> <span class="keywordflow">return</span> 0; <span class="comment">// return for false result</span></div>
<div class="line"><span class="lineno"> 104</span> }</div>
<div class="line"><span class="lineno"> 105</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">&#9670;&nbsp;</a></span>main()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int main </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>main function </p>
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 37</span>{</div>
<div class="line"><span class="lineno"> 38</span> <span class="keywordtype">char</span> infix[20], postfix[20]; <span class="comment">// initialize empty infix and postfix array</span></div>
<div class="line"><span class="lineno"> 39</span> </div>
<div class="line"><span class="lineno"> 40</span> printf(<span class="stringliteral">&quot;Enter infix expression: &quot;</span>); <span class="comment">// example : A+B-C*D/E$F</span></div>
<div class="line"><span class="lineno"> 41</span> scanf(<span class="stringliteral">&quot;%s&quot;</span>, infix); <span class="comment">// get values for infix array</span></div>
<div class="line"><span class="lineno"> 42</span> </div>
<div class="line"><span class="lineno"> 43</span> <a class="code hl_function" href="../../db/d0c/infix__to__postfix_8c.html#a92af69ffc1e1f965ebce6a44672e96b1">convert</a>(infix, postfix);</div>
<div class="line"><span class="lineno"> 44</span> printf(<span class="stringliteral">&quot;Postfix expression is %s&quot;</span>, postfix); <span class="comment">// output : AB+CD*EF$/-</span></div>
<div class="line"><span class="lineno"> 45</span> </div>
<div class="line"><span class="lineno"> 46</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 47</span>}</div>
<div class="ttc" id="ainfix__to__postfix_8c_html_a92af69ffc1e1f965ebce6a44672e96b1"><div class="ttname"><a href="../../db/d0c/infix__to__postfix_8c.html#a92af69ffc1e1f965ebce6a44672e96b1">convert</a></div><div class="ttdeci">void convert(char infix[], char postfix[])</div><div class="ttdoc">convert function</div><div class="ttdef"><b>Definition:</b> infix_to_postfix.c:130</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/d0c/infix__to__postfix_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="332" height="240"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="a940cdcd27c40699eebb4ef113b2d9451" name="a940cdcd27c40699eebb4ef113b2d9451"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a940cdcd27c40699eebb4ef113b2d9451">&#9670;&nbsp;</a></span>pop()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int pop </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../dd/d10/struct_stack.html">Stack</a> *&#160;</td>
<td class="paramname"><em>p</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>pop function </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">*p</td><td>: used as a pointer variable of stack </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>x or \0 on exit </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 73</span>{</div>
<div class="line"><span class="lineno"> 74</span> <span class="keywordtype">char</span> x;</div>
<div class="line"><span class="lineno"> 75</span> </div>
<div class="line"><span class="lineno"> 76</span> <span class="keywordflow">if</span> (p-&gt;<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ac2dbef151bc913684a90b06836725ef9">tos</a> == -1)</div>
<div class="line"><span class="lineno"> 77</span> {</div>
<div class="line"><span class="lineno"> 78</span> printf(<span class="stringliteral">&quot;Stack Underflow!&quot;</span>);</div>
<div class="line"><span class="lineno"> 79</span> <span class="keywordflow">return</span> <span class="charliteral">&#39;\0&#39;</span>;</div>
<div class="line"><span class="lineno"> 80</span> }</div>
<div class="line"><span class="lineno"> 81</span> </div>
<div class="line"><span class="lineno"> 82</span> x = p-&gt;arr[p-&gt;<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ac2dbef151bc913684a90b06836725ef9">tos</a>]; <span class="comment">// assign the value of stack at index tos to x</span></div>
<div class="line"><span class="lineno"> 83</span> p-&gt;<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ac2dbef151bc913684a90b06836725ef9">tos</a> -= 1; <span class="comment">// decrement tos</span></div>
<div class="line"><span class="lineno"> 84</span> </div>
<div class="line"><span class="lineno"> 85</span> <span class="keywordflow">return</span> x;</div>
<div class="line"><span class="lineno"> 86</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a613462735d30cae1b85b606ecab30554" name="a613462735d30cae1b85b606ecab30554"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a613462735d30cae1b85b606ecab30554">&#9670;&nbsp;</a></span>push()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void push </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="../../dd/d10/struct_stack.html">Stack</a> *&#160;</td>
<td class="paramname"><em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>x</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>push function </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">*p</td><td>: used as a pointer variable of stack </td></tr>
<tr><td class="paramname">x</td><td>: char to be pushed in stack </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 56</span>{</div>
<div class="line"><span class="lineno"> 57</span> <span class="keywordflow">if</span> (p-&gt;<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ac2dbef151bc913684a90b06836725ef9">tos</a> == 9) <span class="comment">// check if stack has reached its max limit</span></div>
<div class="line"><span class="lineno"> 58</span> {</div>
<div class="line"><span class="lineno"> 59</span> printf(<span class="stringliteral">&quot;Stack Overflow!&quot;</span>);</div>
<div class="line"><span class="lineno"> 60</span> <span class="keywordflow">return</span>;</div>
<div class="line"><span class="lineno"> 61</span> }</div>
<div class="line"><span class="lineno"> 62</span> </div>
<div class="line"><span class="lineno"> 63</span> p-&gt;<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ac2dbef151bc913684a90b06836725ef9">tos</a> += 1; <span class="comment">// increment tos</span></div>
<div class="line"><span class="lineno"> 64</span> p-&gt;arr[p-&gt;<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ac2dbef151bc913684a90b06836725ef9">tos</a>] = x; <span class="comment">// assign char x to index of stack pointed by tos</span></div>
<div class="line"><span class="lineno"> 65</span>}</div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_9babc524d57e25f3d9f4179cabc3599e.html">conversions</a></li><li class="navelem"><a class="el" href="../../db/d0c/infix__to__postfix_8c.html">infix_to_postfix.c</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
</ul>
</div>
</body>
</html>