How do I know if I have stomach cancer or an ulcer?

MD. The only way to know for sure is seeing your doc for an evaluation. Very likely he/ she will send you to a gastroenterologist, who will do a scope (egd). Best to you.