Problem p00015 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

void rev_str(char str[1024]) {
  int length = 0;
  char str2[1024];
  int temp;

  int i;

  for (i = 0; i < 1024; i++)
    str2[i] = '\\0';

  while (str[length])
    length++;

  temp = length;
  i = 0;
  while (temp) {
    str2[temp - 1] = str[i];
    i++;
    temp--;
  }

  for (i = 0; i < length; i++)
    str[i] = str2[i];
}

int exor(int a, int b) {
  if (a && b)
    return 0;
  else if (a || b)
    return 1;
  else
    return 0;
}

int main() {
  char input_a[1024];
  char input_b[1024];
  char ans[286][1024];
  char kuriagari;
  int temp;
  int n;

  int i, j;

  scanf("%d", &n);

  for (j = 0; j < n; j++) {
    for (i = 0; i < 1024; i++) {
      input_a[i] = '\\0';
      input_b[i] = '\\0';
      ans[j][i] = '\\0';
    }

    kuriagari = 0;

    scanf("%s", input_a);
    scanf("%s", input_b);

    rev_str(input_a);
    rev_str(input_b);

    i = 0;
    while (input_a[i] && input_b[i]) {
      temp = input_a[i] + input_b[i] - 2 * '0' + kuriagari;
      ans[j][i] = temp % 10 + '0';
      kuriagari = temp / 10;
      i++;
    }

    if (kuriagari && !input_a[i] && !input_b[i]) {
      ans[j][i] = kuriagari + '0';
    }

    else {
      while (kuriagari && exor((int)input_a[i], (int)input_b[i])) {
        temp = input_a[i] + input_b[i] - '0' + kuriagari;
        ans[j][i] = (char)(temp % 10 + '0');
        kuriagari = temp / 10;
        i++;
      }

      if (kuriagari)
        ans[j][i] = kuriagari + '0';
    }

    while (input_b[i]) {
      ans[j][i] = input_b[i];
      i++;
    }

    while (input_a[i]) {
      ans[j][i] = input_a[i];
      i++;
    }

    rev_str(ans[j]);

    if (ans[j][80])
      printf("overflow");
    else
      printf("%s", ans[j]);

    putchar('\\n');
  }

  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>

void rev_str(char str[128]) {
  int length = 0;
  char str2[128];
  int temp;

  int i;

  for (i = 0; i < 128; i++)
    str2[i] = '\\0';

  while (str[length])
    length++;

  temp = length;
  i = 0;
  while (temp) {
    str2[temp - 1] = str[i];
    i++;
    temp--;
  }

  for (i = 0; i < length; i++)
    str[i] = str2[i];
}

int exor(int a, int b) {
  if (a && b)
    return 0;
  else if (a || b)
    return 1;
  else
    return 0;
}

int main() {
  char input_a[128];
  char input_b[128];
  char ans[286][128];
  char kuriagari;
  int temp;
  int n;

  int i, j;

  scanf("%d", &n);

  for (j = 0; j < n; j++) {
    for (i = 0; i < 128; i++) {
      input_a[i] = '\\0';
      input_b[i] = '\\0';
      ans[j][i] = '\\0';
    }

    kuriagari = 0;

    scanf("%s", input_a);
    scanf("%s", input_b);

    rev_str(input_a);
    rev_str(input_b);

    i = 0;
    while (input_a[i] && input_b[i]) {
      temp = input_a[i] + input_b[i] - 2 * '0' + kuriagari;
      ans[j][i] = temp % 10 + '0';
      kuriagari = temp / 10;
      i++;
    }

    if (kuriagari && !input_a[i] && !input_b[i]) {
      ans[j][i] = kuriagari + '0';
    }

    else {
      while (kuriagari && exor((int)input_a[i], (int)input_b[i])) {
        temp = input_a[i] + input_b[i] - '0' + kuriagari;
        ans[j][i] = (char)(temp % 10 + '0');
        kuriagari = temp / 10;
        i++;
      }

      if (kuriagari)
        ans[j][i] = kuriagari + '0';
    }

    while (input_b[i]) {
      ans[j][i] = input_b[i];
      i++;
    }

    while (input_a[i]) {
      ans[j][i] = input_a[i];
      i++;
    }

    rev_str(ans[j]);
  }

  for (j = 0; j < n; j++) {
    if (ans[j][81])
      printf("overflow");
    else
      printf("%s", ans[j]);

    putchar('\\n');
  }

  return 0;
}