"A cup of hot coffee" or "A hot cup of coffee"
Solution 1:
They are both grammatical. In principle they could have different meanings, but situations in which the difference is important are rare.
Google ngrams shows that "cup of hot coffee" has always been more common in written sources than "hot cup of coffee" - much more common between about 1850 and 1960, and since then only somewhat more common.
"Hot cup of coffee" could be seen as a kind of metonymy, though the cup is likely to be hot as well, so it can be taken literally. But ngrams shows a similar pattern with "cup of strong coffee"/"strong cup of coffee" (again with the former being much more common for a period, in this case between 1820 and 1930, and since then only somewhat more common), which can only be metonymic.
Solution 2:
Surely the issue is whether the 'cup' is treated distinctly from the coffee. If I want my coffee in a cup then the cup is an intrinsic part of my order, so my adjective applies to the whole caboodle
A hot cup-of-coffee
As well as placing hot in this position I might also say strong / milky / sweet / mountain-fresh
It's certainly not set in stone because I do ask for
A cup of hot coffee
But I think I would then likely be expressing a preference for a cup rather rather than, say, a mug.
Solution 3:
It is perhaps interesting to also consider tea, and the transatlantic differences in language.
UK ngrams
US ngrams
It's clear that in the US, people serve a cup of hot tea far more often than they serve a nice hot cup of tea.
I'd argue that this is probably because, in the US, people have been known to drink cold tea. Not just "cooled down from boiling with a little milk", not "just taken for a splash in Boston harbor", but, would you believe, tea to which they have added ice. They call it "ice tea", the 'd' having been accidentally struck out by a musket ball in the war of 1812. This is not an aberration of a few delinquents, either: it takes up about 85% of modern American tea drinking!
So, long story short, outside of New England, the term "tea" on its own, unqualified, typically means the iced variety.
So, to the American, the requirement is to differentiate from the more usual iced tea, so the term "hot tea" is used for clarity.
To the Briton, a "cup of tea" is more often a cuppa tea, and the nice hot cup of tea is in fact very slightly in the lead in recent years. Superlatives that serve no real purpose other than to emphasize the goodness of the offering, like "nice" and "hot" are often prepended to the compound term "cup of tea", rather than splitting it.
The same applies to coffee (and "ice coffee")
Solution 4:
"A cup of hot coffee"
- The cup's state is mentioned separately from the coffee's, with preference for a cup more particularly tied to the request (vs. a mug) due to its precedent placement.
"A hot cup of coffee"
- The heat takes precedence this time, to the vessel and contents. To me, this implies that not only are both the cup and coffee requested hot, but that the vessel is less important in relation to the temperature.
Solution 5:
Both are correct sentences, but could lead to confusion:
Is the cup hot or the coffee hot?
A cup of hot coffee
In this sentence, the coffee is hot, but the cup might not be.
A hot cup of coffee
In this sentence, grammar would suggest that the cup is hot, but the coffee might not be.