All pastes #222468 Raw Edit

Anonymous

public text v1 · immutable
#222468 ·published 2006-10-26 09:29 UTC
rendered paste body
int     my_putstr(char *str);
#include <stdlib.h>
#include <unistd.h>
void    my_putchar(char c);

int     str_is_op(char *str)
{
  if (str == "+" || str == "-" || str =="/" || str == "*" || str == "%" ||
      str == "(" || str == ")")
    {
      return (1);
    }
  else
    {
      return (0);
    }
  return (2);
}

char    *parser(char *str, int taille)
{
  int   i;
  char  *dest;
  char  *stack;
  char  tmp;

  stack = malloc(sizeof(*stack)*taille);
  dest = malloc(sizeof(*dest)*taille);
  tmp = malloc(sizeof(tmp)*taille);
  i = 0;
  while (str[i])
    {
      tmp = str[i];
      if (str_is_op(*tmp) == 1)
      {
        stack[i] = str[i];
        my_putchar('#');
      }
      if (str_is_op(tmp) == 0)
        {
          dest[i] = str[i];
          my_putstr("chiffre");
          my_putchar('\n');
        }
      i++;
    }
  return (stack);
}

int     main()
{
  char *str;

  str = "+++";
  my_putstr(parser(str, 3));
  return (0);
}