Visiting a dying person can be rather awkward because there is nothing you can say that won't sound shallow and irrelevant at a time like this. You want to comfort - to encourage - to let them know you care - but what do you say?
Try this. SAY NOTHING.
Many people make the obligatory statement, "How are you?" or "How are you doing?" and then, after the polite "I'm fine," go on to talk about themselves or the weather or the latest events in the news. Whatever it takes to keep silence from making you both uncomfortable. But try to be a listener. THAT is the best possible thing you can do.
"Tell me about your life. What were you like as a child." "Do you remember when you and I got in trouble at the beach when we were flirting with those girls...?" "I know now isn't one of them, but what do you think was the best period of your life?" The dying person needs, more than anything else (often but not always) to talk and for someone to listen. Memories are the best avenue to get your friend talking. And, if he or she is too weak to talk, you can talk, sharing common memories that paint vivid word pictures of a life lived well and life enjoyed in better times.
If you are a person of faith, ask questions about your friend's faith. Don't preach. Just let them know that you are holding them up before God and that you will continue to do so.
It is not uncommon for a dying person to want to talk about dying. You may find this uncomfortable. Get over it. Death is around the corner and talking about it helps - both your dying friend and you. The dying person often NEEDS to express his or her concerns or fears or questions. You don't need to have the answers (say "I just don't know"). You aren't expected to. No one is. It's the asking of the questions that is the helpful thing. So much as possible discuss those questions.
Tears are OK. When you are immersed in memories or discussions about death, emotion comes naturally to the surface. You won't be the first your friend has seen with tears. He or she may find it quite beneficial to share those tears with you.