All pastes #577101 Raw Edit

Stuff

public text v1 · immutable
·published 2007-06-19 19:46 UTC
rendered paste body
int
main (void)
{
  int i = 0;
  char buf[256];
  char n1[64], n2[64];
  int nb, nb1, nb2;
  int test = 0;
  char *p, *p2, *ret;

  printf("Entrer le nombre\n");
  scanf("%s", &buf);

  printf("buf: %s\n", buf);

  p = buf;
  p2 = buf;

  while ((isdigit(*p)) && (*p != 0))
    p++;

  if (*p == '/')
    {
      strncpy(n1, p2, p - p2);
      nb1 = atoi(n1);
      test++;
    }

  p++;
  strncpy(n2, p, p - p2);
  nb2 = atoi(n2);

  if (!test)
    nb = atoi(buf);
  else
    nb = nb1/nb2;

  return 0;
}