Warnings I get--how do I increase my compiler warning level? I am using gcc on linux if it matters
//ThousandthPrime: Calculate the thousandthprime.
//primality function which will determine if a number is prime.
long Primality(long n)
//check to see if the number is a multiple of 2(ie the number is even) and is not equal to 2
if(n % 2 == 0 && n != 2)
return false; //if the number is even or equal to 2, return false and do not count these numbers
//once we determine that a number is not even or equal to 2, we can check the odds.
for(long i = 3; i * i <= n; i += 2)
if(n % i == 0)
}//end function primality
long primes = 0;// counts the number of primes for us.
long n = 1; //variable that we will run through primality function
long y = 0; //variable input by the user to tell how many primes to find.
printf("Please enter a number(n), and the program will return with the \"nth\" number of primes: ");
//while loop calls the primality functions until "y" primes are found
while(primes < &y)
printf("I found %ld primes %ld is the \"nth\" prime", primes, n);
This is what happens when I run my code.
ThousandthPrime.c: In function ‘main’:ThousandthPrime.c:32:2: warning: format ‘%ld’ expects argument of type ‘long int *’, but argument 2 has type ‘long int’ [-Wformat]
ThousandthPrime.c:35:15: warning: comparison between pointer and integer [enabled by default]
Please enter a number(n), and the program will return with the "nth" number of primes: 9
Segmentation fault (core dumped)