N
N
Nick_2282019-12-16 11:05:06
C++ / C#
Nick_228, 2019-12-16 11:05:06

How to perform a vertical check in the C language (C) in a two-dimensional array?

It is necessary for each cell of a two-dimensional array to check whether it is worth "0" in neighboring cells. I use it through 2 nested for loops: if array[x - 1][y] == 0 and array [x][y - 1] then... It works horizontally, but not vertically.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CityCat4, 2019-12-16
@Nick_228

Since in fact all arrays in memory are one-dimensional :) moving vertically is just jumping through N cells of the array, where N is its horizontal width. Increment the current pointer by (N * cell_size_array) - and you will get to the next element vertically.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question