简体   繁体   中英

Segmentation Fault on a recursive FloodFill Algorithm

我分配了两种方法来实现Floodfill算法:递归void RFloodFill(PGM * entrada,int x,int y,unsigned char corAtual,

If I understand your problem correctly, the seg fault is occurring when x = -1 and y = 0. This is because you are trying to assign a value to a negative index in the matrix which is not allowed. Since you are trying to modify a place in memory you dont have access to, it seg faults.

saida->imagem[x][y]=corAtual; if x is negative here, it will seg fault here, as it is before the check to see if x > 0

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