Process returned -10737341818错误原因及解决办法

hmmmmm之前很多bug自己没有总结,从今天开始慢慢把自己的bug记录一下

好的贴代码

int main(int argc, char* argv[])
{
using namespace std;
///无量纲测试
    ofstream fout("testRungeKutta.dat");
    const scalar _deltT =0.01;
    const scalar _mStar = 2.4;
    const scalar _dampRatio = 0.0059;
    const scalar _uStar =5;
    rungeKutta object_test(_mStar,_dampRatio,_uStar,_deltT);

    scalar amplitude = 0.5;
    scalar frequency = 0.5;
    scalar omega = 2*PI*frequency;
    struct movements
    {   scalar time_i;
        scalar yDisplacement;
        scalar yVelocity;
        scalar yAccelaration;
        //scalar Cl = amplitude*(omega*_deltT);
    };

//    vector m_move;
//    vector time;
//    vector Cl;


scalar* y_displacement = new scalar [1000];
scalar* y_velocity = new scalar[1000];
scalar* y_Acceleration = new scalar[1000];
scalar* time_i =new scalar [1000];
scalar* force_Cl = new scalar[1000];
y_displacement[0] = 0.0;
y_velocity[0] = 0.0;
y_Acceleration[0] = 0.0;
for(int i =0;i<1000;i++)
{
    time_i[i] = i*_deltT;
    force_Cl[i] = amplitude*sin(omega*time_i[i]);
object_test.Set(force_Cl[i]);
object_test.CalculateDisplacement(y_velocity[i],y_displacement[i]);
    y_velocity[i+1]=object_test.Velocity();
    y_displacement[i+1]=object_test.Displacement();
    y_Acceleration[i+1]=object_test.Displacement();
    time_i[i+1] = (i+1)*_deltT;
    cout<

主程序段,我cout和fout的时候应该是把数组的下标搞越界了。在for()循环里面吧改成i<999,返回就没有这个错误了。

你可能感兴趣的:(bug,C++)