TheAlgorithms-C/da/d96/infix__to__postfix2_8c.html

502 lines
40 KiB
HTML
Raw Normal View History

<!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.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C: conversions/infix_to_postfix2.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.4 -->
<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('da/d96/infix__to__postfix2_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> &#124;
<a href="#var-members">Variables</a> </div>
<div class="headertitle"><div class="title">infix_to_postfix2.c File Reference</div></div>
</div><!--header-->
<div class="contents">
<p><a href="https://www.includehelp.com/c/infix-to-postfix-conversion-using-stack-with-c-program.aspx" target="_blank">Infix to Postfix converter</a> implementation
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;string.h&gt;</code><br />
<code>#include &lt;ctype.h&gt;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
<code>#include &lt;stdint.h&gt;</code><br />
<code>#include &lt;assert.h&gt;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for infix_to_postfix2.c:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d1/de4/infix__to__postfix2_8c__incl.svg" width="524" 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:a90e051f23f741be4f8ca86c270d66489"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d96/infix__to__postfix2_8c.html#a90e051f23f741be4f8ca86c270d66489">push</a> (char opd)</td></tr>
<tr class="memdesc:a90e051f23f741be4f8ca86c270d66489"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to push on the stack. <a href="../../da/d96/infix__to__postfix2_8c.html#a90e051f23f741be4f8ca86c270d66489">More...</a><br /></td></tr>
<tr class="separator:a90e051f23f741be4f8ca86c270d66489"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a312e7f6c761a199c1369fbe651e084f0"><td class="memItemLeft" align="right" valign="top">char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d96/infix__to__postfix2_8c.html#a312e7f6c761a199c1369fbe651e084f0">pop</a> ()</td></tr>
<tr class="memdesc:a312e7f6c761a199c1369fbe651e084f0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to pop from the stack. <a href="../../da/d96/infix__to__postfix2_8c.html#a312e7f6c761a199c1369fbe651e084f0">More...</a><br /></td></tr>
<tr class="separator:a312e7f6c761a199c1369fbe651e084f0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a653c98c68c558505b75b04c44b7c838e"><td class="memItemLeft" align="right" valign="top">uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d96/infix__to__postfix2_8c.html#a653c98c68c558505b75b04c44b7c838e">isEmpty</a> ()</td></tr>
<tr class="memdesc:a653c98c68c558505b75b04c44b7c838e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to check whether the stack is empty or not. <a href="../../da/d96/infix__to__postfix2_8c.html#a653c98c68c558505b75b04c44b7c838e">More...</a><br /></td></tr>
<tr class="separator:a653c98c68c558505b75b04c44b7c838e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2d1c13296ce9c42bb5dd7d834e2802bf"><td class="memItemLeft" align="right" valign="top">char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d96/infix__to__postfix2_8c.html#a2d1c13296ce9c42bb5dd7d834e2802bf">Top</a> ()</td></tr>
<tr class="memdesc:a2d1c13296ce9c42bb5dd7d834e2802bf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to get top of the stack. <a href="../../da/d96/infix__to__postfix2_8c.html#a2d1c13296ce9c42bb5dd7d834e2802bf">More...</a><br /></td></tr>
<tr class="separator:a2d1c13296ce9c42bb5dd7d834e2802bf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a02d1bf0ff997efc46ba6fd0ec7952952"><td class="memItemLeft" align="right" valign="top">int16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d96/infix__to__postfix2_8c.html#a02d1bf0ff997efc46ba6fd0ec7952952">priority</a> (char opr)</td></tr>
<tr class="memdesc:a02d1bf0ff997efc46ba6fd0ec7952952"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to check priority of operators. <a href="../../da/d96/infix__to__postfix2_8c.html#a02d1bf0ff997efc46ba6fd0ec7952952">More...</a><br /></td></tr>
<tr class="separator:a02d1bf0ff997efc46ba6fd0ec7952952"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae363a3863a8bfbf40e7a95c2b9dbe71b"><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d96/infix__to__postfix2_8c.html#ae363a3863a8bfbf40e7a95c2b9dbe71b">convert</a> (char inf[])</td></tr>
<tr class="memdesc:ae363a3863a8bfbf40e7a95c2b9dbe71b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function to convert infix expression to postfix expression. <a href="../../da/d96/infix__to__postfix2_8c.html#ae363a3863a8bfbf40e7a95c2b9dbe71b">More...</a><br /></td></tr>
<tr class="separator:ae363a3863a8bfbf40e7a95c2b9dbe71b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa8dca7b867074164d5f45b0f3851269d"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../da/d96/infix__to__postfix2_8c.html#aa8dca7b867074164d5f45b0f3851269d">test</a> ()</td></tr>
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Self-test implementations. <a href="../../da/d96/infix__to__postfix2_8c.html#aa8dca7b867074164d5f45b0f3851269d">More...</a><br /></td></tr>
<tr class="separator:aa8dca7b867074164d5f45b0f3851269d"><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="../../da/d96/infix__to__postfix2_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function. <a href="../../da/d96/infix__to__postfix2_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">More...</a><br /></td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="var-members" name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:a791cc5e78425bce611db4e3bdc4b19d5"><td class="memItemLeft" align="right" valign="top"><a id="a791cc5e78425bce611db4e3bdc4b19d5" name="a791cc5e78425bce611db4e3bdc4b19d5"></a>
struct <a class="el" href="../../dd/d10/struct_stack.html">Stack</a>&#160;</td><td class="memItemRight" valign="bottom"><b>st</b></td></tr>
<tr class="memdesc:a791cc5e78425bce611db4e3bdc4b19d5"><td class="mdescLeft">&#160;</td><td class="mdescRight">global declaration of stack st <br /></td></tr>
<tr class="separator:a791cc5e78425bce611db4e3bdc4b19d5"><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://www.includehelp.com/c/infix-to-postfix-conversion-using-stack-with-c-program.aspx" target="_blank">Infix to Postfix converter</a> implementation </p>
<p >The input infix expression is of type string upto 24 characters. Supported operations- '+', '-', '/', '*', '' </p><dl class="section author"><dt>Author</dt><dd><a href="https://github.com/kumaryash18" target="_blank">Kumar Yash</a> </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="../../db/d0c/infix__to__postfix_8c.html" title="Infix to Postfix Expression Conversion">infix_to_postfix.c</a> </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="ae363a3863a8bfbf40e7a95c2b9dbe71b" name="ae363a3863a8bfbf40e7a95c2b9dbe71b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae363a3863a8bfbf40e7a95c2b9dbe71b">&#9670;&nbsp;</a></span>convert()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">char * convert </td>
<td>(</td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>inf</em>[]</td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Function to convert infix expression to postfix expression. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">inf</td><td>the input infix expression </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>output postfix expression </dd></dl>
<p >&lt; to store the postfix expression</p>
<p >&lt; loop iterator</p>
<p >&lt; keeps track of end of postfix string</p>
<div class="fragment"><div class="line"><span class="lineno"> 100</span> {</div>
<div class="line"><span class="lineno"> 101</span> <span class="keyword">static</span> <span class="keywordtype">char</span> post[25]; <span class="comment">///&lt; to store the postfix expression</span></div>
<div class="line"><span class="lineno"> 102</span> <span class="keywordtype">int</span> i; <span class="comment">///&lt; loop iterator</span></div>
<div class="line"><span class="lineno"> 103</span> <span class="keywordtype">int</span> j = 0; <span class="comment">///&lt; keeps track of end of postfix string</span></div>
<div class="line"><span class="lineno"> 104</span> <span class="keywordflow">for</span>(i = 0; i &lt; strlen(inf); i++) {</div>
<div class="line"><span class="lineno"> 105</span> <span class="keywordflow">if</span>(isalnum(inf[i])) { <span class="comment">// if scanned element is an alphabet or number</span></div>
<div class="line"><span class="lineno"> 106</span> post[j] = inf[i]; <span class="comment">// append in postfix expression</span></div>
<div class="line"><span class="lineno"> 107</span> j++;</div>
<div class="line"><span class="lineno"> 108</span> }</div>
<div class="line"><span class="lineno"> 109</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span>(inf[i] == <span class="charliteral">&#39;(&#39;</span>) { <span class="comment">// if scanned element is opening parentheses</span></div>
<div class="line"><span class="lineno"> 110</span> <a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a90e051f23f741be4f8ca86c270d66489">push</a>(inf[i]); <span class="comment">// push on stack.</span></div>
<div class="line"><span class="lineno"> 111</span> }</div>
<div class="line"><span class="lineno"> 112</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span>(inf[i] == <span class="charliteral">&#39;)&#39;</span>) { <span class="comment">// if scanned element is closing parentheses,</span></div>
<div class="line"><span class="lineno"> 113</span> <span class="keywordflow">while</span>(<a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a2d1c13296ce9c42bb5dd7d834e2802bf">Top</a>() != <span class="charliteral">&#39;(&#39;</span>) { <span class="comment">// pop elements from stack and append in postfix expression</span></div>
<div class="line"><span class="lineno"> 114</span> post[j] = <a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a312e7f6c761a199c1369fbe651e084f0">pop</a>(); <span class="comment">// until opening parentheses becomes top.</span></div>
<div class="line"><span class="lineno"> 115</span> j++;</div>
<div class="line"><span class="lineno"> 116</span> }</div>
<div class="line"><span class="lineno"> 117</span> <a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a312e7f6c761a199c1369fbe651e084f0">pop</a>(); <span class="comment">// pop opening parentheses</span></div>
<div class="line"><span class="lineno"> 118</span> }</div>
<div class="line"><span class="lineno"> 119</span> <span class="keywordflow">else</span> { <span class="comment">// if scanned element is an operator</span></div>
<div class="line"><span class="lineno"> 120</span> <span class="keywordflow">while</span>( (!<a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a653c98c68c558505b75b04c44b7c838e">isEmpty</a>()) &amp;&amp; (<a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a02d1bf0ff997efc46ba6fd0ec7952952">priority</a>(inf[i]) &lt;= <a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a02d1bf0ff997efc46ba6fd0ec7952952">priority</a>(<a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a2d1c13296ce9c42bb5dd7d834e2802bf">Top</a>())) ) { <span class="comment">// pop and append until stack becomes</span></div>
<div class="line"><span class="lineno"> 121</span> post[j] = <a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a312e7f6c761a199c1369fbe651e084f0">pop</a>(); <span class="comment">// empty or priority of top operator</span></div>
<div class="line"><span class="lineno"> 122</span> j++; <span class="comment">// becomes smaller than scanned operator</span></div>
<div class="line"><span class="lineno"> 123</span> } <span class="comment">// &#39;(&#39; has priority -1</span></div>
<div class="line"><span class="lineno"> 124</span> <a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a90e051f23f741be4f8ca86c270d66489">push</a>(inf[i]); <span class="comment">// push the scanned operator</span></div>
<div class="line"><span class="lineno"> 125</span> }</div>
<div class="line"><span class="lineno"> 126</span> }</div>
<div class="line"><span class="lineno"> 127</span> <span class="keywordflow">while</span>(!<a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a653c98c68c558505b75b04c44b7c838e">isEmpty</a>()) { <span class="comment">// pop and append residual operators from stack</span></div>
<div class="line"><span class="lineno"> 128</span> post[j] = <a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#a312e7f6c761a199c1369fbe651e084f0">pop</a>();</div>
<div class="line"><span class="lineno"> 129</span> j++;</div>
<div class="line"><span class="lineno"> 130</span> }</div>
<div class="line"><span class="lineno"> 131</span> post[j] = <span class="charliteral">&#39;\0&#39;</span>; <span class="comment">// end postfix string with null character</span></div>
<div class="line"><span class="lineno"> 132</span> <span class="keywordflow">return</span> post;</div>
<div class="line"><span class="lineno"> 133</span>}</div>
<div class="ttc" id="ainfix__to__postfix2_8c_html_a02d1bf0ff997efc46ba6fd0ec7952952"><div class="ttname"><a href="../../da/d96/infix__to__postfix2_8c.html#a02d1bf0ff997efc46ba6fd0ec7952952">priority</a></div><div class="ttdeci">int16_t priority(char opr)</div><div class="ttdoc">Function to check priority of operators.</div><div class="ttdef"><b>Definition:</b> infix_to_postfix2.c:83</div></div>
<div class="ttc" id="ainfix__to__postfix2_8c_html_a2d1c13296ce9c42bb5dd7d834e2802bf"><div class="ttname"><a href="../../da/d96/infix__to__postfix2_8c.html#a2d1c13296ce9c42bb5dd7d834e2802bf">Top</a></div><div class="ttdeci">char Top()</div><div class="ttdoc">Function to get top of the stack.</div><div class="ttdef"><b>Definition:</b> infix_to_postfix2.c:72</div></div>
<div class="ttc" id="ainfix__to__postfix2_8c_html_a312e7f6c761a199c1369fbe651e084f0"><div class="ttname"><a href="../../da/d96/infix__to__postfix2_8c.html#a312e7f6c761a199c1369fbe651e084f0">pop</a></div><div class="ttdeci">char pop()</div><div class="ttdoc">Function to pop from the stack.</div><div class="ttdef"><b>Definition:</b> infix_to_postfix2.c:45</div></div>
<div class="ttc" id="ainfix__to__postfix2_8c_html_a653c98c68c558505b75b04c44b7c838e"><div class="ttname"><a href="../../da/d96/infix__to__postfix2_8c.html#a653c98c68c558505b75b04c44b7c838e">isEmpty</a></div><div class="ttdeci">uint16_t isEmpty()</div><div class="ttdoc">Function to check whether the stack is empty or not.</div><div class="ttdef"><b>Definition:</b> infix_to_postfix2.c:61</div></div>
<div class="ttc" id="ainfix__to__postfix2_8c_html_a90e051f23f741be4f8ca86c270d66489"><div class="ttname"><a href="../../da/d96/infix__to__postfix2_8c.html#a90e051f23f741be4f8ca86c270d66489">push</a></div><div class="ttdeci">void push(char opd)</div><div class="ttdoc">Function to push on the stack.</div><div class="ttdef"><b>Definition:</b> infix_to_postfix2.c:32</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="../../da/d96/infix__to__postfix2_8c_ae363a3863a8bfbf40e7a95c2b9dbe71b_cgraph.svg" width="195" 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="a653c98c68c558505b75b04c44b7c838e" name="a653c98c68c558505b75b04c44b7c838e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a653c98c68c558505b75b04c44b7c838e">&#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="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Function to check whether the stack is empty or not. </p>
<p >Returns 1 if stack is empty, returns 0 if not empty.</p>
<dl class="section return"><dt>Returns</dt><dd>1 if the stack IS empty </dd>
<dd>
0 if the stack is NOT empty </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 61</span> {</div>
<div class="line"><span class="lineno"> 62</span> <span class="keywordflow">if</span>(<a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ad62fb36816185f3eef3a6f735a61f54a">top</a> == -1) {</div>
<div class="line"><span class="lineno"> 63</span> <span class="keywordflow">return</span> 1;</div>
<div class="line"><span class="lineno"> 64</span> }</div>
<div class="line"><span class="lineno"> 65</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 66</span>}</div>
<div class="ttc" id="ainfix__to__postfix2_8c_html_a791cc5e78425bce611db4e3bdc4b19d5"><div class="ttname"><a href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a></div><div class="ttdeci">struct Stack st</div><div class="ttdoc">global declaration of stack st</div><div class="ttdef"><b>Definition:</b> infix_to_postfix2.c:25</div></div>
<div class="ttc" id="astruct_stack_html_ad62fb36816185f3eef3a6f735a61f54a"><div class="ttname"><a href="../../dd/d10/struct_stack.html#ad62fb36816185f3eef3a6f735a61f54a">Stack::top</a></div><div class="ttdeci">int top</div><div class="ttdoc">stores index of the top element</div><div class="ttdef"><b>Definition:</b> infix_to_postfix2.c:23</div></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>
<p >initialize</p>
<p >run self-test implementations</p>
<p >&lt; to store input infix expression</p>
<div class="fragment"><div class="line"><span class="lineno"> 156</span> {</div>
<div class="line"><span class="lineno"> 157</span> <a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ad62fb36816185f3eef3a6f735a61f54a">top</a> = -1; <span class="comment">/// initialize</span></div>
<div class="line"><span class="lineno"> 158</span> <a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">/// run self-test implementations</span></div>
<div class="line"><span class="lineno"> 159</span> <span class="keywordtype">char</span> inf[25]; <span class="comment">///&lt; to store input infix expression</span></div>
<div class="line"><span class="lineno"> 160</span> printf(<span class="stringliteral">&quot;Enter infix: &quot;</span>);</div>
<div class="line"><span class="lineno"> 161</span> scanf(<span class="stringliteral">&quot;%s&quot;</span>, inf);</div>
<div class="line"><span class="lineno"> 162</span> printf(<span class="stringliteral">&quot;Postfix: %s&quot;</span>, <a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#ae363a3863a8bfbf40e7a95c2b9dbe71b">convert</a>(inf));</div>
<div class="line"><span class="lineno"> 163</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 164</span>}</div>
<div class="ttc" id="ainfix__to__postfix2_8c_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../da/d96/infix__to__postfix2_8c.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition:</b> infix_to_postfix2.c:139</div></div>
<div class="ttc" id="ainfix__to__postfix2_8c_html_ae363a3863a8bfbf40e7a95c2b9dbe71b"><div class="ttname"><a href="../../da/d96/infix__to__postfix2_8c.html#ae363a3863a8bfbf40e7a95c2b9dbe71b">convert</a></div><div class="ttdeci">char * convert(char inf[])</div><div class="ttdoc">Function to convert infix expression to postfix expression.</div><div class="ttdef"><b>Definition:</b> infix_to_postfix2.c:100</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="../../da/d96/infix__to__postfix2_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="386" 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="a312e7f6c761a199c1369fbe651e084f0" name="a312e7f6c761a199c1369fbe651e084f0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a312e7f6c761a199c1369fbe651e084f0">&#9670;&nbsp;</a></span>pop()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pop </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Function to pop from the stack. </p>
<p >Pop data from the stack.</p>
<dl class="section return"><dt>Returns</dt><dd>popped character </dd></dl>
<p >&lt; to store the popped value to be returned</p>
<div class="fragment"><div class="line"><span class="lineno"> 45</span> {</div>
<div class="line"><span class="lineno"> 46</span> <span class="keywordtype">char</span> item; <span class="comment">///&lt; to store the popped value to be returned</span></div>
<div class="line"><span class="lineno"> 47</span> <span class="keywordflow">if</span>(<a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ad62fb36816185f3eef3a6f735a61f54a">top</a> == -1) { <span class="comment">// underflow condition</span></div>
<div class="line"><span class="lineno"> 48</span> printf(<span class="stringliteral">&quot;Stack underflow...&quot;</span>);</div>
<div class="line"><span class="lineno"> 49</span> exit(1);</div>
<div class="line"><span class="lineno"> 50</span> }</div>
<div class="line"><span class="lineno"> 51</span> item = <a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#a856ca6f4a9ffde43f0cb3b43cb4d044d">stack</a>[<a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ad62fb36816185f3eef3a6f735a61f54a">top</a>];</div>
<div class="line"><span class="lineno"> 52</span> <a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ad62fb36816185f3eef3a6f735a61f54a">top</a>--;</div>
<div class="line"><span class="lineno"> 53</span> <span class="keywordflow">return</span> item;</div>
<div class="line"><span class="lineno"> 54</span>}</div>
<div class="ttc" id="astruct_stack_html_a856ca6f4a9ffde43f0cb3b43cb4d044d"><div class="ttname"><a href="../../dd/d10/struct_stack.html#a856ca6f4a9ffde43f0cb3b43cb4d044d">Stack::stack</a></div><div class="ttdeci">char stack[10]</div><div class="ttdoc">array stack</div><div class="ttdef"><b>Definition:</b> infix_to_postfix2.c:22</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a02d1bf0ff997efc46ba6fd0ec7952952" name="a02d1bf0ff997efc46ba6fd0ec7952952"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a02d1bf0ff997efc46ba6fd0ec7952952">&#9670;&nbsp;</a></span>priority()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int16_t priority </td>
<td>(</td>
<td class="paramtype">char&#160;</td>
<td class="paramname"><em>opr</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Function to check priority of operators. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">opr</td><td>operator whose priority is to be checked </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 if operator is '+' or '-' </dd>
<dd>
1 if operator is '/' or '*' or '' </dd>
<dd>
-1 otherwise </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 83</span> {</div>
<div class="line"><span class="lineno"> 84</span> <span class="keywordflow">if</span>(opr == <span class="charliteral">&#39;+&#39;</span> || opr == <span class="charliteral">&#39;-&#39;</span>) {</div>
<div class="line"><span class="lineno"> 85</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 86</span> }</div>
<div class="line"><span class="lineno"> 87</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span>(opr == <span class="charliteral">&#39;/&#39;</span> || opr == <span class="charliteral">&#39;*&#39;</span> || opr == <span class="charliteral">&#39;%&#39;</span>) {</div>
<div class="line"><span class="lineno"> 88</span> <span class="keywordflow">return</span> 1;</div>
<div class="line"><span class="lineno"> 89</span> }</div>
<div class="line"><span class="lineno"> 90</span> <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 91</span> <span class="keywordflow">return</span> -1;</div>
<div class="line"><span class="lineno"> 92</span> }</div>
<div class="line"><span class="lineno"> 93</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a90e051f23f741be4f8ca86c270d66489" name="a90e051f23f741be4f8ca86c270d66489"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a90e051f23f741be4f8ca86c270d66489">&#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">char&#160;</td>
<td class="paramname"><em>opd</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Function to push on the stack. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">opd</td><td>character to be pushed in the 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"> 32</span> {</div>
<div class="line"><span class="lineno"> 33</span> <span class="keywordflow">if</span>(<a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ad62fb36816185f3eef3a6f735a61f54a">top</a> == 9) { <span class="comment">// overflow condition</span></div>
<div class="line"><span class="lineno"> 34</span> printf(<span class="stringliteral">&quot;Stack overflow...&quot;</span>);</div>
<div class="line"><span class="lineno"> 35</span> exit(1);</div>
<div class="line"><span class="lineno"> 36</span> }</div>
<div class="line"><span class="lineno"> 37</span> <a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ad62fb36816185f3eef3a6f735a61f54a">top</a>++;</div>
<div class="line"><span class="lineno"> 38</span> <a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#a856ca6f4a9ffde43f0cb3b43cb4d044d">stack</a>[<a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ad62fb36816185f3eef3a6f735a61f54a">top</a>] = opd;</div>
<div class="line"><span class="lineno"> 39</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="aa8dca7b867074164d5f45b0f3851269d" name="aa8dca7b867074164d5f45b0f3851269d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa8dca7b867074164d5f45b0f3851269d">&#9670;&nbsp;</a></span>test()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static void test </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Self-test implementations. </p>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<p >this ensures that the algorithm works as expected</p>
<p >this ensures that the algorithm works as expected</p>
<div class="fragment"><div class="line"><span class="lineno"> 139</span> {</div>
<div class="line"><span class="lineno"> 140</span> <span class="comment">/* check sample test case</span></div>
<div class="line"><span class="lineno"> 141</span><span class="comment"> input- &quot;(A/(B-C)*D+E)&quot;</span></div>
<div class="line"><span class="lineno"> 142</span><span class="comment"> expected output- &quot;ABC-/D*E+&quot;</span></div>
<div class="line"><span class="lineno"> 143</span><span class="comment"> */</span></div>
<div class="line"><span class="lineno"> 144</span> assert(strcmp(<a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#ae363a3863a8bfbf40e7a95c2b9dbe71b">convert</a>(<span class="stringliteral">&quot;(A/(B-C)*D+E)&quot;</span>), <span class="stringliteral">&quot;ABC-/D*E+&quot;</span>) == 0); <span class="comment">/// this ensures that the algorithm works as expected</span></div>
<div class="line"><span class="lineno"> 145</span> <span class="comment">/* input- &quot;7-(2*3+5)*(8-4/2)&quot;</span></div>
<div class="line"><span class="lineno"> 146</span><span class="comment"> expected output- &quot;723*5+842/-*-&quot;</span></div>
<div class="line"><span class="lineno"> 147</span><span class="comment"> */</span></div>
<div class="line"><span class="lineno"> 148</span> assert(strcmp(<a class="code hl_function" href="../../da/d96/infix__to__postfix2_8c.html#ae363a3863a8bfbf40e7a95c2b9dbe71b">convert</a>(<span class="stringliteral">&quot;7-(2*3+5)*(8-4/2)&quot;</span>), <span class="stringliteral">&quot;723*5+842/-*-&quot;</span>) == 0); <span class="comment">/// this ensures that the algorithm works as expected</span></div>
<div class="line"><span class="lineno"> 149</span> printf(<span class="stringliteral">&quot;All tests have successfully passed!\n&quot;</span>);</div>
<div class="line"><span class="lineno"> 150</span>}</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="../../da/d96/infix__to__postfix2_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg" width="287" 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="a2d1c13296ce9c42bb5dd7d834e2802bf" name="a2d1c13296ce9c42bb5dd7d834e2802bf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2d1c13296ce9c42bb5dd7d834e2802bf">&#9670;&nbsp;</a></span>Top()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">char Top </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Function to get top of the stack. </p>
<dl class="section return"><dt>Returns</dt><dd>top of stack </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 72</span> {</div>
<div class="line"><span class="lineno"> 73</span> <span class="keywordflow">return</span> <a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#a856ca6f4a9ffde43f0cb3b43cb4d044d">stack</a>[<a class="code hl_variable" href="../../da/d96/infix__to__postfix2_8c.html#a791cc5e78425bce611db4e3bdc4b19d5">st</a>.<a class="code hl_variable" href="../../dd/d10/struct_stack.html#ad62fb36816185f3eef3a6f735a61f54a">top</a>];</div>
<div class="line"><span class="lineno"> 74</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="../../da/d96/infix__to__postfix2_8c.html">infix_to_postfix2.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.4 </li>
</ul>
</div>
</body>
</html>