首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

运行报错解决方法

2012-04-24 
运行报错运行中断,显示“FPS.exe中的0x77661884处未处理的异常:0xC0000005:读取位置0xfff7ffff时发生访问冲

运行报错
运行中断,显示“FPS.exe中的0x77661884处未处理的异常:0xC0000005:读取位置0xfff7ffff时发生访问冲突”,请问这是什么意思啊?谢谢

在main函数里调用这个tridag(u,data_out_b,lambda,m);就出错,不用这句话就好了

下面是代码,

C/C++ code
#include<iostream>#include<cmath>#include<fftw3.h>#define PI 3.1415926using namespace std;void lu_lower(double d[],double e[],double b[],double x[],int n){    x[0]=b[0]/d[0];    int count;    for(count=1;count<=n-1;count++)    {        x[count]=(b[count]-e[count-1]*x[count-1])/d[count];    }}void lu_upper(double d[],double e[],double b[], double x[],int n){    x[n-1]=b[n-1]/d[n-1];    int count;    for(count=n-2;count>=0;count--)    {        x[count]=(b[count]-e[count]*x[count+1])/d[count];    }}void tridag(double u[],double r[],double lambda,int n){    double d[10];//按照实际情况调整    double e[9];    double temp[10];    d[0]=sqrt(lambda);    e[0]=-1/d[0];    int count;    for(count=1;count<=n-2;count++)    {        d[count]=sqrt((lambda-d[count-1]*d[count-1]));        e[count]=-1/d[count];    }    d[n-1]=sqrt((lambda-d[n-2]*d[n-2]));    lu_lower(d,e,r,temp,n);    lu_upper(d,e,temp,u,n);}int main()//最终结果在temp里,把它拉成一维看就行{    int m=10;//FFT的维数,符号和书上统一    int dm=2*m;//把N化成2N,才能用FFT求解    int p=1;//符号和书上统一    double data_out_b[10];    double u[10];//追赶法的解向量    int count;    int count1;    double lambda;    double temp[1][10]={{1,2,3,4,5,6,7,8,9,10}};//存放b的数据,一共有m*p个,p行m列        fftw_complex *in;    fftw_complex *out;    fftw_plan plan;    in=(fftw_complex*) fftw_malloc(sizeof(fftw_complex)*dm);    out=(fftw_complex*) fftw_malloc(sizeof(fftw_complex)*dm);    plan=fftw_plan_dft_1d(dm,in,out,FFTW_FORWARD,FFTW_ESTIMATE);        for(count=1;count<=p;count++)    {        lambda=4-cos(p*PI/(m+1));                **in=0;*(*in+1)=0;        for(count1=1;count1<=m;count1++)        {            in++;            **in=temp[count-1][count1-1];            *(*in+1)=0;        }        for(count1=1;count1<=m-1;count1++)        {            in++;            **in=0;            *(*in+1)=0;        }        in=in-m;        fftw_execute(plan);        for(count1=1;count1<=m;count1++)        {            out++;            data_out_b[count1-1]=(**out);        }        out=out-m;                tridag(u,data_out_b,lambda,m);        for(count1=1;count1<=m;count1++)        {            in++;            **in=u[count1-1];            *(*in+1)=0;        }        fftw_execute(plan);        for(count1=1;count1<=m;count1++)        {            out++;            temp[count-1][count1-1]=(**out);        }    }    int countm,countp;    for(countp=1;countp<=p;countp++)    {        for(countm=1;countm<=m;countm++)        {            cout<<temp[countp-1][countm-1]<<endl;                    }    }    fftw_destroy_plan(plan);    fftw_free(in);fftw_free(out);                    system("pause");    return 0;}


[解决办法]
探讨

问下,我传进函数的数组有100个元素,但是函数里面只用到前十个数,请问这样还会有越界的问题么?

热点排行