"Enough" and "enough of" are quantifiers describing the noun that follows. So, yes, there is a difference; it may
seem subtle, but it isn't exactly. There is an implied meaning, and you have to decide which meaning you want to convey to your reader. If it helps, think of "enough of" as the experience of X.
In King Neptune's response, the example "I had enough to eat" implies I am full; I don't need to eat any more. The example "I had enough of his foolishness" implies I am not putting up with it anymore or for all time.
Either could be correct.
I had enough to eat.
I had enough of his foolishness.
etc.
It depends on what you are writing.
"I've had enough chocolate."
"I've had enough of chocolate."
Two different things. Presumably you mean something like the latter.
In morngnstar's examples: "I've had enough chocolate" implies I need to stop eating chocolate and eat something else for now, or I can't eat any more chocolate right now. The example "I've had enough of chocolate" implies I've had enough of the experience of eating chocolate (and all that entails).
In a scene I'm writing, I've given a basic description of the protagonist's apartment, essentially spartan with wide open spaces. This leads up to why he prefers this style.
Which sentence is correct?
He'd had enough living in cramped quarters during his stint with the Marines
He'd had enough of living in cramped quarters during his stint with the Marines.
Or is there a better way to say it?
In your examples, the meaning is slightly more subtle. But, as others have said, context is everything. If you wish to convey that he'd had enough living in cramped quarters and
he certainly isn't going to do that now, use your first example. If you wish to convey that he has had enough of living in cramped quarters and will never do it again, use your second example as it refers to the experience he intends to never repeat.