c - 程序停止工作并在C中返回值3221225477
问题描述
我有这个问题,我的程序输出屏幕中的错误号为 3221225477。五百大小的数组运行没有错误,但一千多万是关键的。编码:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <time.h>
#include "windows.h"
#include "psapi.h"
int size;
int array[];
time_t tStart;
time_t tEnd;
double sum;
double avg;
void reading(char pName[]){
int i=0;
FILE *f;
if ((f=fopen(pName,"r"))==NULL){
printf("file failed to open\n");
}
else{
while(i < size){
if (fscanf(f, "%d", &array[i])!= EOF){
//printf("%d\n", array[i]);
i++;
}
else{
break;
}
}
}
fclose(f);
}
void insertionSort() {
int i,j;
int temp;
for (i = 1; i < size; i++) {
temp = array[i];
j=i-1;
while((j >= 0) && (temp < array[j])) {
array[j + 1]= array[j];
j--;
}
array[j + 1]= temp;
}
}
void toString(){
int i;
for(i=0; i < size; i++){
printf("%d ", array[i]);
}
}
void test(int pSize, char pName[]){
size = pSize;
array[size];
int i;
for(i=0; i < 200; i++){
reading(pName);
time(&tStart);
insertionSort();
time(&tEnd);
reading(pName);
time(&tStart);
insertionSort();
time(&tEnd);
sum = sum + ((double) (tEnd - tStart) / 1000000);
}
avg = sum / 200;
printf("avg= %f\n", avg);
}
void testing(){
test(500,"500.txt");
test(1000,"1000.txt");
test(40000,"40000.txt");
}
int main(){
testing();
}
你有什么想法来解决这个问题吗?
txt文件示例:
5
89
1516
15689
88
568
684
.
.
.
size is a name of file
目的代码是比较两种排序算法之间经过的时间。(是的,在代码中只有一次,两次)
解决方案
推荐阅读
- duplicates - 从 Salesforce 中删除重复资产
- angular - 选择一个选项并重新聚焦后,Angular Material Autocomplete 会错误地显示所有选项
- python - 如何在 Pandas Python 3.X 中划分两个数据帧,并将 NaN、inf 值替换为 0
- android - android studio中构建失败:文件名必须以.xml或.png结尾
- java - 如何修补java库?
- emacs - 在 Geiser/Emacs 中编译 Chicken 文件的问题
- python - Tkinter:在背景图像上覆盖标签
- javascript - 在点击方法vue js上显示元素
- spring-boot - Docker 中的 Sap Java 连接器应用程序
- git - 在`git rebase --abort`和origin remove之后继续rebase