找了很多遍了,还是没找出错误的原因,求高手指点迷津!
运行一下代码,输入值《=80时,正常运行输出;而输入值大于80时,fopen打开出错!
想了很久,觉得可能是本人对fopen还不够了解~
//Program 12.4 Page 464
#define _STDC_WANT_LIB_EXT1_ 1
#include
#include
#include
#include
#include
#define PER_LINE 8
#define MEM_PRIMES 80
struct
{
char *filename;
FILE *pfile;
unsigned long long primes[MEM_PRIMES];
size_t count;
}global={.filename=”myfile.bin”,.pfile=NULL,.primes={2ULL,3ULL,5ULL},.count=3};
bool is_prime(unsigned long long trial);
void list_primes(void);
void write_file(unsigned long long primes[],size_t n);
int main(void)
{
size_t total=0;
printf(“How many primes do you want to print out? “);
scanf_s(