0
關於結構化文本編程語言:結構化文本 - 與非關聯表指針偏移
如果我有一個指針表:
crcTable : ARRAY [0..255] OF WORD;
pcrcTable : POINTER TO WORD;
pcrcTable := ADR(crcTable);
,我想提領表在一定的指數,是什麼是這樣做的語法嗎?我認爲等效的C代碼將是:
unsigned short crcTable[256];
unsigned short* pcrcTable = &crcTable[0];
dereferencedVal = pcrcTable[50]; //Grab table value at index = 50
對於我使用指針的範圍,我沒有可見性的原始crcTable ...只是指針。所以我不能使用你的「Dereference index 3」例子。我試着做類似這樣的事情:pcrcTable:= pcrcTable + 3 * SIZEOF(pcrcTable ^);但是我有一個語法錯誤。 – user2913869
關於crcTable在您想要使用指針的位置不可見的好處。 :-) 我相信「pcrcTable:= pcrcTable + n * SIZEOF(crcVal3);」應該管用。關鍵是你應該允許你將任何東西添加到指針中,而SIZEOF()僅用於爲它添加一個單詞的大小。 – pboedker
如果pcrcTable是一個輸入變量,您可能不允許更改它。相反,使用「pcrcTableLocal:= pcrcTable + n * SIZEOF(crcVal3);」在設置crcVal3之前:= pcrcTableLocal ^; – pboedker