Iは、配列を有する:[I] [0] [1]も上書き[I] [1] [0]及びその逆
typedef short int long_graph[1000][1000][1];
私はそれを宣言する:
long_graph paf_graph;
を
は私が機能を持っている:
:私はここでの問題を検出しvoid construct_paf_graph (sf::Vector2i A,sf::Vector2i B, long_graph &paf_graph, long_list &paf_list, poly_list &poly, int &no_of_poly_on_map, list_of_indexes &XX )
{
short int n,i,j,k,e, t, off; // t is used to convert indices from individual polies to the unified list
bool path_clear;
short int distance, rev_en_ind; // reverse engineer index
n=0; //will be total number of points in paf_graph and paf_list
t=0;
std::fstream debug;
debug.open("assets/debug.txt", std::ios::out | std::ios::trunc);
for (i=1; i<=XX[0]; i+=1)
{
debug << XX[i] << "\n";
for (j=1; j<= poly[XX[i]].point[0].x; j+=1)
{
n+=1;
paf_graph[n][0][0] = poly[XX[i]].graph[j][0][0];
//paf_graph[n][0][1] = i;
debug << "P["<<n<<"] = " << paf_graph[n][0][1] << " \n";
for (k=1; k<= poly[XX[i]].graph[j][0][0]; k+=1)
{
paf_graph[n][k][0] = poly[XX[i]].graph[j][k][0] + t;
paf_graph[n][k][1] = poly[XX[i]].graph[j][k][1];
debug << " P["<<n<<"] = " << paf_graph[n][0][1] << " " << "k="<<k<< " c="<<poly[XX[i]].graph[j][k][0] + t<<" \n";
if (k==1) debug << "\n\n PP = " << paf_graph[n][k][0] << " " << poly[XX[i]].graph[j][k][0] + t <<"\n";
}
off = paf_graph[n][1][0];
paf_graph[n][0][1] = i;
//paf_graph[n][1][0] = off;
paf_list[n].x = poly[XX[i]].point[j].x;
paf_list[n].y = poly[XX[i]].point[j].y;
}
debug << "\n";
t+= poly[XX[i]].point[0].x;
}
paf_graph[0][0][0] = n;
paf_list[0].x = n;
// function continues some more
より大きなコードブロックに見られるように
210はI 3つの余分な行を入れて、この奇妙な現象を単離する:配列自体は
off = paf_graph[n][1][0];
paf_graph[n][0][1] = i; //this line also writes i to [n][1][0]
//paf_graph[n][1][0] = off; //if I take the comment off this line it will
// write "off" to [n][0][1] as well
//so whatever I do they both have the same value
//and one is always wrong
奇妙なことである[1000] [1000] [1]ショートINTおよびそれ以外の座標については正常に動作します。 私はそれを小さくしようとしましたが[100] [100] [1]問題は同じです、渡される値は100未満です。
配列は関数への参照として渡され、後でメインブロックで使用され、[i] [0] [1] [i] [1] [0] 。
残念ながら、コードは非常に大きいので、私はすべてのコードを投稿できませんが、問題が上記の部分に分離されていることを二重チェックしました。
この奇妙な現象が起こっている理由が分かっている人は、助けてください。
これは私がおそらくmingwコンパイラで知られているエラーですので、コードブロックにタグを付けましたか?
とにかく、アドバイスありがとうございました。
ありがとうございました!私はそのようなルーキーミスのために落ちたとは信じられません。 – user3515319