title: Delimiter matching in c++ - segmentation fault (core dumped)
body: <p>I keep getting the segmentation fault error when running my program. I have no clue what is wrong. I googled the error message, I just don't know what it means. Any help would be great!</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include &lt;stack&gt;
  using namespace std;
  
  bool delimiterMatching(char *file){
    stack&lt;char&gt; x;
    int count = 0;
    char ch, onTop, check;
    while(ch != '/n'){
      ch = file[count];
      if (ch == '(' || '[' || '{')
        x.push(ch);
  
      else if (ch == ')' || ']' || '}') {
        onTop == x.top();
        x.pop();
        if((ch==')' &amp;&amp; onTop!='(') || (ch==']' &amp;&amp; onTop!='[') || (ch=='}' &amp;&amp;
                                  onTop!= '{'))
      return false;        
      }
  
    count++;
    }
  
    if (x.empty())
      return true;
    else 
      return false;
  
  }
  
  
  int main()
  {
    char test[50];
    cout &lt;&lt; "enter sentence: ";
    cin &gt;&gt; test;
  
      if (delimiterMatching(test))
      cout &lt;&lt; "success" &lt;&lt; endl;
    else 
      cout &lt;&lt; "error" &lt;&lt; endl;
  
    return 1;
  }
  </code></pre>