简体   繁体   中英

2D Arrays and C

Do C compilers differ in the way they treat 2D arrays in C (not C++)? I am doing image processing in C, and it seems to me that dealing with 2D arrays is the most intuitive way, as opposed to a 1D array.

I've also developed some algorithms on my Windows machine to process images by denoising or smoothing. The question I have is should I be worried about carrying these algorithms to another C compiler if I am using a 2D array to store images and filters? Will things hit the fan if one uses 2D arrays in C in the long run? So the essence of this question is how safe are 2D arrays in C?

Thanks.

C really only has 1-dimensional arrays. A 2D array is simply a 1D array where each element is itself a 1D array. Compilers treat such arrays identically, so you shouldn't have any problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM