title: Popping a float into a char to use as ascii code gives off a crash
body: <pre><code>  while (!isEmpty(s))
      {
          *c = pop(s);
          strcat(postfix, c);
          strcat(postfix, &quot; &quot;);
      }
  </code></pre>
  <p>This is where the crash happens specifically at the *c line. When i display the stack it has a value of 43.00000 which means it contains the '+' in ASCI code.
  I also used these 3 lines above this specific one in two loops which gave no error.</p>
  <pre><code>float pop(stack *s)
  {
      float x = s-&gt;top-&gt;data;
      node *temp = s-&gt;top;
      s-&gt;top = s-&gt;top-&gt;next;
      free(temp);
      return x;
  }
  </code></pre>
  <p>Here is the pop function.
  Also this works in vscode and the crashes happen in codeblocks only</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;math.h&gt;
  #include &lt;ctype.h&gt;
  typedef struct node
  {
      float data;
      struct node *next;
  } node;
  typedef struct
  {
      node *top;
  } stack;
  node *newNode(float x)
  {
      node *n = malloc(sizeof(node));
      n-&gt;data = x;
      n-&gt;next = NULL;
      return n;
  }
  stack *init()
  {
      stack *s = malloc(sizeof(stack));
      s-&gt;top = NULL;
      return s;
  }
  float pop(stack *s)
  {
      float x = s-&gt;top-&gt;data;
      node *temp = s-&gt;top;
      s-&gt;top = s-&gt;top-&gt;next;
      free(temp);
      return x;
  }
  void push(stack *s, float x)
  {
      node *n = newNode(x);
      if (s-&gt;top == NULL)
          s-&gt;top = n;
      else
      {
          n-&gt;next = s-&gt;top;
          s-&gt;top = n;
      }
  }
  float peek(stack *s)
  {
      float x = s-&gt;top-&gt;data;
      return x;
  }
  int isEmpty(stack *s)
  {
      return (s-&gt;top == NULL);
  }
  void display(stack *s)
  {
      stack *temp = init();
      while (!isEmpty(s))
          push(temp, pop(s));
      while (!isEmpty(temp))
      {
          printf(&quot;%f &quot;, peek(temp));
          push(s, pop(temp));
      }
      printf(&quot;\n&quot;);
  }
  int priority(char op)
  {
      if (op == '+' || op == '-')
          return 1;
      if (op == '*' || op == '/')
          return 2;
      if (op == '^')
          return 3;
      else
          return 0;
  }
  int isOperator(char op[5])
  {
      if (!strcmp(op, &quot;+&quot;) || !strcmp(op, &quot;-&quot;) || !strcmp(op, &quot;*&quot;) || !strcmp(op, &quot;/&quot;) || !strcmp(op, &quot;^&quot;) || !strcmp(op, &quot;(&quot;) || !strcmp(op, &quot;)&quot;))
          return 1;
      else
          return 0;
  }
  int isDigit(char digit[20])
  {
      int i = 0;
      if (digit[0] == '-')
          i++;
      for (i; digit[i] != '\0'; i++)
          if (!isdigit(digit[i]) &amp;&amp; digit[i] != '.')
              return 0;
      return 1;
  }
  char *infixToPostfix(char *infix)
  {
      char postfix[100] = &quot;&quot;, tokens[20][2000], *temptok, *c;
      int i = 0;
      temptok = strtok(infix, &quot; &quot;);
      strcpy(tokens[i++], temptok);
      while (temptok != NULL)
      {
          temptok = strtok(NULL, &quot; &quot;);
          if (temptok != NULL)
              strcpy(tokens[i++], temptok);
      }
      int ntok = i;
      stack *s = init();
      for (i = 0; i &lt; ntok; i++)
      {
          if (isDigit(tokens[i]) &amp;&amp; strcmp(tokens[i], &quot;-&quot;))
          {
              strcat(postfix, tokens[i]);
              strcat(postfix, &quot; &quot;);
          }
          else if (isOperator(tokens[i]))
          {
              if (isEmpty(s))
                  push(s, tokens[i][0]);
              else if (tokens[i][0] == '(')
                  push(s, tokens[i][0]);
              else if (tokens[i][0] == ')')
              {
                  while (peek(s) != '(')
                  {
                      *c = pop(s);
                      strcat(postfix, c);
                      strcat(postfix, &quot; &quot;);
                  }
                  pop(s);
              }
              else
              {
                  while (!isEmpty(s) &amp;&amp; priority(peek(s)) &gt;= priority(tokens[i][0]) &amp;&amp; tokens[i][0] != '(')
                  {
                      *c = pop(s);
                      strcat(postfix, c);
                      strcat(postfix, &quot; &quot;);
                  }
                  push(s, tokens[i][0]);
              }
          }
      }
      display(s);
      system(&quot;pause&quot;);
      while (!isEmpty(s))
      {
          *c = pop(s);
          strcat(postfix, c);
          strcat(postfix, &quot; &quot;);
      }
      strcpy(infix, postfix);
      return infix;
  }
  int main()
  {
      char infixExpr[256] = &quot;&quot;;
      printf(&quot;Enter an expression you want to evaluate or Ctrl+Z to exit: &quot;);
      while (fgets(infixExpr, 255, stdin) != NULL)
      {
          replaceNewLineBySpace(infixExpr);
          char *postfix = infixToPostfix(infixExpr);
          printf(&quot;Postfix : %s\n&quot;, postfix);
          float result = evaluatePostfix(postfix);
          printf(&quot;Result: %f\n&quot;, result);
          system(&quot;pause&quot;);
          // exit(1);
      }
      return 0;
  }
  </code></pre>