title: AddressSanitizer:DEADLYSIGNAL when trying to use a user input
body: <p>here is the code that i have:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;stdbool.h&gt;
  #include &lt;assert.h&gt;
  #include &lt;time.h&gt;
  
  const int Win = 0, Lose = 1, Draw = 2;
  const int Rock = 0, Paper = 1, Scissors = 2;
  
  int input(int n, char i[n]){
    if (i[0] == 'R' || i[0] == 'r') return Rock;
    else if (i[0] == 'P' || i[0] == 'p') return Paper;
    else if (i[0] == 'S' || i[0] == 's') return Scissors;
    else return -1;
  }
  
  int game(int n){
    srand(time(NULL));
    int r = rand() % 2;
    if (r == n) return Draw;
    else if (r == 0 &amp;&amp; n == 1) return Win;
    else if (r == 0 &amp;&amp; n == 2) return Lose;
    else if (r == 1 &amp;&amp; n == 0) return Lose;
    else if (r == 1 &amp;&amp; n == 2) return Win;
    else if (r == 2 &amp;&amp; n == 0) return Win;
    else if (r == 2 &amp;&amp; n == 1) return Lose;
    else return 0;
  }
  
  void print(int game){
    if (game == Draw &amp;&amp; input == Rock) printf ("i chose rock, its a draw\n");
    else if (game == Draw &amp;&amp; input == Paper) printf ("i chose paper, its a draw\n");
    else if (game == Draw &amp;&amp; input == Scissors) printf ("i chose scissors, its a draw\n");
    else if (game == Win &amp;&amp; input == Rock) printf ("i chose scissors, you win\n");
    else if (game == Win &amp;&amp; input == Paper) printf ("i chose rock, you win\n");
    else if (game == Win &amp;&amp; input == Scissors) printf ("i chose paper, you win\n");
    else if (game == Lose &amp;&amp; input == Rock) printf ("i chose paper, you lose\n");
    else if (game == Lose &amp;&amp; input == Paper) printf ("i chose scissors, you lose\n");
    else printf ("i chose rock, you lose\n");
  }
  
  // void checkInput(){
  //     assert(input(1, 'R') == 1);
  //     assert(input(1, 'r') == 1);
  //     assert(input(1, 'P') == 2);
  //     assert(input(1, 'p') == 2);
  //     assert(input(1, 'S') == 3);
  //     assert(input(1, 's') == 3);
  //     printf("all tests pass\n");
  // }
  
  int main(){
    setbuf(stdout, NULL);
    char *j[1];
    for(int a = 0; a &gt;= 0; a++){
      printf("pick rock, paper, scissors (R/P/S) 'e' to exit\n");
      scanf("%s", &amp;*j[0]);
      if (j[0] == 'e') break;
      print(game(input(strlen(j[0]), j[0])));
    }
    return 0;
  }
  </code></pre>
  
  <p>when i run it prints out the line and lets me input something after which it gives me this error</p>
  
  <pre><code>pick rock, paper, scissors (R/P/S) 'e' to exit
  R
  AddressSanitizer:DEADLYSIGNAL
  =================================================================
  ==4029==ERROR: AddressSanitizer: SEGV on unknown address 0x7f5ca33d6787 (pc 0x7f5ca328ffdd bp 0x7ffca0431550 sp 0x7ffca0430e70 T0)
  ==4029==The signal is caused by a WRITE memory access.
      #0 0x7f5ca328ffdc  (/lib/x86_64-linux-gnu/libc.so.6+0x6cfdc)
      #1 0x7f5ca329f12b  (/lib/x86_64-linux-gnu/libc.so.6+0x7c12b)
      #2 0x4a724c  (/home/student/Documents/extra+0x4a724c)
      #3 0x4a734e  (/home/student/Documents/extra+0x4a734e)
      #4 0x512a5e  (/home/student/Documents/extra+0x512a5e)
      #5 0x7f5ca3244b96  (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
      #6 0x419e19  (/home/student/Documents/extra+0x419e19)
  
  AddressSanitizer can not provide additional info.
  SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x6cfdc) 
  ==4029==ABORTING
  </code></pre>
  
  <p>how can i stop this from happening as this error means nothing to me, and cant see anything that could be wrong with it. I know i have pasted a lot of code but i figure you need to see all of it to have an idea where it is crashing from.</p>