And you start to put notes and you soon give up.
But that's because you are thinking wrong. Real melodies go like this:
1231 2123 4512 3412 3123 4561 2345 6712 3123 4123 456
Ok what is THAT?
Each numbers represent a note. And 123 means 1 and 2 and 3 are CONNECTED.
[4beats] [4beats] [4beats] [4beats]
1231 2123 4512 3412 3123 4561 2345 6712 3123 4123 456
[connected short line],[connected short line], [connected short line], ...
123,12,12345, ...
->
123,1 2,123 45,12 34,12 3,123, ....
When you put notes instead of numbers:
CDE,C D,CDE FG,CD EF,CD E,CDE, ... (you don't actually do this but it sounds kinda good actually....)
How to distinguish connected short lines inside a melody? Those short lines makes up a melody and when a CHORD change, those short lines change.
It means, you don't FIT a melody inside a 4/4 time you make melody with FREEDOM and PLAY it inside that time measure.
Those 123,12,12345 kind of pattern's tend to change when genre and style and era changes. Just like melodies and chords.
Also, in real music each note's length differs. Not everything is 8th it could be 16th, 4th etc. And, there also could be a rest between each note.

PS. For newb composers: To be able to do all this, you need to select a TONE of a song. Tone is like a white noise. But it stays in your mind and represents the whole song. Tone is more of a ground than building blocks and if you choose right ground you will be able to build a building. Without tone there is no music. As song progress, tone also expands. There will be small subset of frequencies in your tone but as song progresses tone will have more sub-frequencies. Tone has speeds, tone has frequencies, tone IS music by itself. There is tone in solo druming, there is tone in jazz, there is tone in electronic music.