[問題] 程式debug一問
#include<iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#include <string.h>
#include <fstream>
#include <math.h>
using std::cout;
using std::endl;
using namespace std;
int main(void)
{
float r[31] = {-0.63121,-0.40549,2.7277,0.78316,1.31013,-1.58676,-0.39346
,-0.8032,0.79537,-1.37385,1.48174,1.83644,0.82119,0.30444,-0.75855,1.05733
,1.06721,-0.4587,0.77037,0.81001,-1.47255,-1.99684,2.42261,0.6552,0.14404
,-2.18021,0.99614,0.37678,0.14944,1.73383,-1.17308};
int s0[1][32]={0};//[a0][time]
int s1[1][32]={0};//[a1][time]
int s2[1][32]={0};//[a2][time]
int s3[1][32]={0};//[a3][time]
int s4[1][32]={0};//[a4][time]
int s5[1][32]={0};//[a5][time]
int s6[1][32]={0};//[a6][time]
int s7[1][32]={0};//[a7][time]
int s8[1][32]={0};//[a8][time]
int s9[1][32]={0};//[a9][time]
int s10[1][32]={0};//[a10][time]
float s[2048][32]={0};//[a10][time]//總和
int v[2048][31]={0};//
float b[2][31]={0};//[branch][time]
float state[1][32]={0};
int codeword[1][31]={0};
double max = 2.0;
for(int i=1;i<=31;i++)
{
b[0][i] = -1*r[i-1];//計算V=0的branch
b[1][i] = 1*r[i-1];//計算V=1的branch
}
///////////////////////////////////////////////////
for(int t=1;t<=11;t++)/////
{
max = pow(2.0, t);
for(int i=0;i<=(max/2)-1;i++)
{
int y=0;
s0[i][t] = (i/1)%2;
s1[i][t] = (i/2)%2;
s2[i][t] = (i/4)%2;
s3[i][t] = (i/8)%2;
s4[i][t] = (i/16)%2;
s5[i][t] = (i/32)%2;
s6[i][t] = (i/64)%2;
s7[i][t] = (i/128)%2;
s8[i][t] = (i/256)%2;
s9[i][t] = (i/1024)%2;
s10[i][t] = (i/2048)%2;
////////////////////////////////////////////////////////////////////////
if(t==1) //2 1bits
{
v[i][t] = s0[i][t];
s[i][t] = s[i][t-1]+b[y][t];
v[i+1][t] = ((v[i][t])+1)%2;
s[i+1][t] = s[i][t-1]+b[(y+1)%2][t];
}
////////////////////////////////////////////////////////////////////////
if(t==2)//4 2bits
{
y = v[i][t] = s1[i][t];
s[i][t] = s[i][t-1] + b[y][t];
v[i+2][t] = ((v[i][t])+1)%2;
s[i+2][t] = s[i][t-1] + b[(y+1)%2][t];
}
////////////////////////////////////////////////////////////////////////
if(t==3)//8 3bits
{
y = v[i][t] = (s0[i][t]+s2[i][t])%2;
s[i][t] = s[i][t-1] + b[y][t];
v[i+4][t] = ((v[i][t])+1)%2;
s[i+4][t] = s[i][t-1] + b[(y+1)%2][t];
}
////////////////////////////////////////////////////////////////
if(t==4)//16 4bits
{
y = v[i][t] = (s1[i][t]+s3[i][t])%2;
s[i][t] = s[i][t-1] + b[y][t];
v[i+8][t] = ((v[i][t])+1)%2;
s[i+8][t] = s[i][t-1] + b[(y+1)%2][t];
}
//////////////////////////////////////////////////////////////////////////////////////
if(t==5)//32 5bits
{
y = v[i][t] = (s0[i][t]+s2[i][t]+s4[i][t])%2;
s[i][t] = s[i][t-1] + b[y][t];
v[i+16][t] = ((v[i][t])+1)%2;
s[i+16][t] = s[i][t-1] + b[(y+1)%2][t];
}
//////////////////////////////////////////////////////////////////////////////////////
if(t==6)//64 6bits
{
y = v[i][t] = (s1[i][t]+s3[i][t]+s5[i][t])%2;
s[i][t] = s[i][t-1] + b[y][t];
v[i+32][t] = ((v[i][t])+1)%2;
s[i+32][t] = s[i][t-1] + b[(y+1)%2][t];
}
小弟先做compiler然後在(t==6)那邊設了一個中斷點
然後F5一步一步跑,但是每試跑到t==6那邊i不固定是多少
就會跑出底下的錯誤訊息
indows has triggered a breakpoint in helloC++.exe.
This may be due to a corruption of the heap, which indicates a bug in
helloC++.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while helloC++.exe has focus.
The output window may have more diagnostic information.
helloC++.exe是我的專題名,我有爬文只知道heap好像是一種記憶體的方式
但是還是不太知道為什麼它會爆
可以請板上的高手解答一下嗎 小弟還是VC新手 所以請板上高手盡量告訴
感謝^^
Unhandled exception at 0x002718f7 in helloC++.exe: 0xC0000005:
Access violation writing location 0x00160004.
有時後又會出現這種,真的是很頭痛
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.122.235
※ 編輯: gw119 來自: 140.113.122.235 (04/30 20:50)
推
04/30 21:52, , 1F
04/30 21:52, 1F
→
04/30 22:01, , 2F
04/30 22:01, 2F
→
04/30 22:02, , 3F
04/30 22:02, 3F
→
04/30 22:51, , 4F
04/30 22:51, 4F
→
04/30 22:52, , 5F
04/30 22:52, 5F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章