title: Segmentation fault while compiling online
body: <p>I have a problem like this:</p>
  
  <p>Players generally sit in a circle. The player designated to go first says the number "1", and each player thenceforth counts one number in turn. However, any number divisible by 'A' e.g. three is replaced by the word fizz and any divisible by 'B' e.g. five by the word buzz. Numbers divisible by both become fizz buzz. A player who hesitates or makes a mistake is either eliminated.</p>
  
  <p>Write a program that prints out the the pattern generated by such a scenario given the values of 'A'/'B' and 'N' which are read from an input text file. The input text file contains three space delimited numbers i.e. A, B, N. The program should then print out the final series of numbers using 'F' for fizz, 'B' for 'buzz' and 'FB' for fizz buzz.</p>
  
  <p>The input is like this:</p>
  
  <p>Your program should read an input file (provided on the command line) which contains multiple newline separated lines. Each line will contain 3 numbers which are space delimited. The first number is first number to divide by ('A' in this example), the second number is the second number to divide by ('B' in this example) and the third number is where you should count till ('N' in this example). You may assume that the input file is formatted correctly and is the numbers are valid positive integers. E.g. </p>
  
  <p>3 5 10</p>
  
  <p>2 7 15 </p>
  
  <p>Output:</p>
  
  <p>Print out the series 1 through N replacing numbers divisible by 'A' by F, numbers divisible by 'B' by B and numbers divisible by both as 'FB'. Since the input file contains multiple sets of values, your output will print out one line per set. Ensure that there are no trailing empty spaces on each line you print. E.g.</p>
  
  <p>1 2 F 4 B F 7 8 F B</p>
  
  <p>1 F 3 F 5 F B F 9 F 11 F 13 FB 15</p>
  
  <p>Constraints:
  The number of test cases &lt;= 20
  "A" is in range [1, 20]
  "B" is in range [1, 20]
  "N" is in range [21, 100]  </p>
  
  <p>Now I wrote the following code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char *argv[])
  {
    int a,b,n,i;
    int part;
    /* char file[200]; */
    /* scanf("%s",file); */
    FILE *f = fopen(argv[1],"r");
  
  while(fscanf(f,"%d %d %d",&amp;a,&amp;b,&amp;n) == 3)
  {
    for ( i = 1 ; i &lt;= n ; i++ )
    {
      if ( i % a == 0 &amp;&amp; i % b == 0 )
      {
          printf("FB ");
          continue;
      }
      if ( i % a == 0 )
      {
          printf("F ");
      }
      else if( i % b == 0 )
      {
          printf("B ");
      }
      else
      {
          printf("%d ",i);
      }
    }
    printf("\n");
  }
  //printf("%d",all);
  return 0;
  }
  </code></pre>
  
  <p>When I am running the above program on my computer it is working well. But in case of online compiling and running, it is giving segmentation fault. Even the file chosen by the online compiler is not giving any error on my computer.
  The file for online compiler is here:</p>
  
  <pre><code>6 14 50
  15 12 53
  14 2 37
  15 11 67
  3 8 100
  12 14 30
  7 12 64
  19 9 97
  20 11 76
  16 10 76
  13 13 53
  1 7 65
  10 13 86
  3 1 60
  4 17 99
  8 10 51
  10 12 65
  10 19 70
  8 17 100
  16 9 52
  </code></pre>
  
  <p>What's wrong with my code?</p>