How to create two dimensional array in Promela?

让人想犯罪 __ 提交于 2019-12-11 05:53:47

问题


To create matrix in C we need to write:

int[][] a = {{1,2,3},{1,2,3},{1,2,3}}

How can I create a matrix in Promela?


回答1:


From the docs:

Multidimensional arrays can be constructed indirectly with the use of typedef definitions.

Also from the docs:

EXAMPLES

The first example shows how to declare a two-dimensional array of elements of type byte with a typedef.

typedef array { /* typedefs must be global */
    byte aa[4]
};
init {
    array a[8];   /* 8x4 = 32 bytes total */
    a[3].aa[1] = 5
}

A better approach is to use one-dimensional arrays.



来源:https://stackoverflow.com/questions/58748279/how-to-create-two-dimensional-array-in-promela

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!