title: Why Do I Get "nested functions are disabled..." Error in my Code?
body: <p>Basically, a program to find the <strong>largest prime factor of a number</strong>. Don't know if the logic is correct cuz I can't run it to test it. I know this is long. But please forgive me.</p>
  
  <pre><code>//largest_prime.c
  #include &lt;stdio.h&gt;
  int main() {
      int num,large;
      int prime(int);
      int lprime(int);
      printf("Enter number: "); 
      scanf("%d",&amp;num);
      large = lprime(num);
      printf("Largest Prime = %d\n",large);
      return 0;
  }
  
  int lprime(int num) {
      int i=num-1,large;
      while (i!=-1) {
          if (num%i==0) {
              if (prime(i)==1) {
                  large=i;
                  i=-1;
              }
              i--;
          }
          return large;
      }
  
      int prime(int num) {
          int prime,i=num-1;
          while (i!=-1) {
              if(num%i==0) {
                  if(i!=1) {
                      i=-1;
                      return 0;
                  }
                  else
                      return 1;
              }
              i--;
          }
      }
  </code></pre>
  
  <p>I get this as output at terminal (I use Mac) using GCC:</p>
  
  <pre><code>largest_prime.c: In function ‘lprime’:
  largest_prime.c:26: error: nested functions are disabled, use -fnested-functions to re-enable
  largest_prime.c:39: error: syntax error at end of input
  </code></pre>
  
  <p>I tried -fnested-functions to re-enable. I get:</p>
  
  <pre><code>largest_prime.c: In function ‘lprime’:
  largest_prime.c:39: error: syntax error at end of input
  </code></pre>
  
  <p>Please Help!</p>