Each loop in the solenoid will have its own magnetic field wrapped around it. In that case it won't resemble the magnetic lines formed by a bar magnet...; but we see that it is the same. Why is that?
By applying Fleming's Right Hand in each turn, we get magnetic field lines that look like this :-
.. .. ..
But Magnetic field lines never intersect. They interact with the fieds of the surrounding turns of solenoid to form a combined magnetic field which looks like this:-
.. .. ..
From www.nde-ed.org :-
The magnetic field circling each loop of wire combines with the fields from the other loops to produce a concentrated field down the centre of the coil. A loosely wound coil is illustrated to show the interaction of the magnetic field. The magnetic field is essentially uniform down the length of the coil when it is wound tighter.
If the loops or turns are extremely close to each other, magnetic field lines between neighbouring turns effectively cancel, resulting in straight magnetic fields inside the solenoid, similar magnetic fields inside a bar magnet :-
.. .. ..
The magnetic field lines around (a) a bar magnet and (b) a current carrying solenoid :-
As in the case of bar-magnets, the magnetic field is stronger inside the solenoid than outside it. Magnetic field lines are closely packed inside the solenoid, and magnetic field is concentrated into a nearly uniform magnetic field inside the solenoid. The magnetic fields outside are weak and spread out.
The first three diagrams are snipped from a video available on YouTube: Concepts in physics - Electromagnetism
Opposite. Solenoid is actually like real magnet bar
Imagine one iron atom. It has electrons run in circle around that atom so it generate magnetic force. Every iron atom is like a solenoid loop by itself
Then Imagine a bar magnet is clump of iron which almost all atoms align in the same direction so every atom contribute a magnetic force. That's it much more like many solenoid loops parallel to each other
In detail you should watch this video
imakesmalltalk's answer is a good description of how the fields superpose in a solenoid to produce a final field similar to a bar magnet, but I want to discuss one or two subtle differences.
The final picture in imakesmalltalk's answer is clearly showing lines of H-field (which are often referred to as magnetic field), because they appear to begin and end at the surface of the magnet, whereas lines of B-field must be continuous. In actual fact there is a weak H-field inside the magnet running in the opposite direction between the poles. In an air-filled solenoid, the lines of H-field are continuous and in the same direction as the B-field. Thus the H-fields of a solenoid and a bar magnet are quite different, though they can be similar outside the solenoid. Another way of saying this is that the air-filled solenoid does not have magnetic poles (sources and sinks of H-field), whereas the bar magnet does.
It is more correct to say that the lines of B-field for a solenoid resemble the lines of B-field for a bar magnet, if the solenoid is of a similar size to the bar magnet. See this diagram from the hyperphysics site. Though note, the labelling of N and S poles on the solenoid is erroneous, in the sense there are no sinks/sources of H-field here and all we are saying is that this arrangement produces a B-field (or exterior H-field) similar to a bar magnet with poles at these positions.