๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Computer Science/ํŒŒ์ด์ฌ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ&sklearn&keras

DataStructure::Segmentation fault 11 error

segmentation fault 11 error๋Š” "๋ฉ”๋ชจ๋ฆฌ, ํฌ์ธํ„ฐ์™€ ๊ด€๋ จ๋œ ์—๋Ÿฌ"์ด๋‹ค. 

์‰ฝ๊ฒŒ ๋งํ•ด์„œ ํฌ์ธํ„ฐ๊ฐ€ ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ์ฃผ์–ด์ง€์ง€ ์•Š์€ ์ด์ƒํ•œ ๊ณต๊ฐ„์„ ๊ฐ€๋ฆฌํ‚ฌ ๊ฒฝ์šฐ์— ๋‚˜๋Š” ์—๋Ÿฌ์ด๋‹ค. 

ํฌ์ธํ„ฐ ๋ณ€์ˆ˜ curr๋ฅผ ์ง€์ •ํ•ด ์คฌ๋Š”๋ฐ, ์ด ๋ณ€์ˆ˜๊ฐ€ ๊ฐ€์ง„ ์ฃผ์†Œ๊ฐ’์ด if ๋ฌธ ์•ˆ์—์„œ ๋ฉ”๋ชจ๋ฆฌ์˜ ๋๊นŒ์ง€ ๊ฐ€๋ฒ„๋ ค์„œ

๋‹ค์Œ for๋ฌธ์—์„œ curr=curr->next ๋•Œ ์—๋Ÿฌ๊ฐ€ ๋‚˜๋Š” ๊ฒƒ์ด์—ˆ๋‹ค.

 

for๋ฌธ์„ ๋‚˜์˜จ ํ›„

๊ทธ๋ž˜์„œ curr->item ๊ฐ’์€ ๋ฌผ๋ก  curr->next์˜ ๊ฐ’์„ ์•Œ๋ ค๊ณ  ํ•  ๋•Œ ๋ฉ”๋ชจ๋ฆฌ ๋ฌธ์ œ๋กœ ์—๋Ÿฌ๊ฐ€ ๋œจ๋Š” ๊ฒƒ์ด์—ˆ๋‹ค.

ํฌ์ธํ„ฐ ๋ณ€์ˆ˜ ์ง€์ •ํ•˜๊ณ  ๋‚œ ํ›„์—” ํ•ญ์ƒ ํฌ์ธํ„ฐ ๋ณ€์ˆ˜๊ฐ€ ์–ด๋–ค ์ฃผ์†Œ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”์ง€ ์œ ๋…ํ•˜๊ธฐ!