They both seems to store files in a decentralized network. So what's the difference between them in terms of data structure and algorithms they use? And also what's the difference between them in terms of use cases?
If I store a file in IPFS or Filecoin, will it remain there forever or it may get lost?
IPFS does storage and content-based addressing. Filecoin is just a way to incentivize people to store IPFS content.
So it's not really easy to tell the difference because they are not comparable. Filecoin just works on top of IPFS.